Skip to Content.
Sympa Menu

k-user - Re: [K-user] List of Maps: possible?

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] List of Maps: possible?


Chronological Thread 
  • From: Daniele Filaretti <dfilaretti AT gmail.com>
  • To: David Lazar <lazar6 AT illinois.edu>
  • Cc: k-user AT cs.uiuc.edu
  • Subject: Re: [K-user] List of Maps: possible?
  • Date: Tue, 31 Jul 2012 11:07:00 +0100
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user>
  • List-id: <k-user.cs.uiuc.edu>

Hi all,
sorry for the slow reply.
In fact I have already solved the problem. Instead of using a list of
environments I'm just using a single "runtime" environment plus a stack where
I save pairs (K, env) when I enter a function (as is on the CHALLENGE
language). It seems to be the an elegant and simple solution.
Thanks a lot for the advice!

Regards,
Daniele

On 31 Jul 2012, at 05:44, David Lazar wrote:

> Hi Daniele,
>
> One possibility is to inject Maps into K and use ~> as a list separator.
>
> For example:
>
> module TEST is
>
> syntax K ::= "append" "(" Map ")"
> syntax K ::= "pop"
>
> configuration
> <k> append(1 |-> 3 2 |-> 1) ~> append(7 |-> 9) ~> pop </k>
> <env> .Map </env>
> <envs> .K </envs>
>
> rule
> <k> append(Env:Map) => . ...</k>
> <envs>... . => Map2K(Env) </envs>
>
> rule
> <k> pop => . ...</k>
> <env> _ => Env </env>
> <envs> Map2K(Env:Map) => . ...</envs>
>
> end module
>
> I hope this helps.
>
> Cheers,
> David
>
> On Thu, Jul 26, 2012 at 7:20 PM, Daniele Filaretti
> <dfilaretti AT gmail.com>
> wrote:
>> Dear all,
>> I'll try to be short: do you know if its possible to define a cell
>> containing a List of Maps (e.g. a list of environments)? If not, do I have
>> to maintain a list of numbers and a separate map from numbers to
>> "environment" cells (each one containing a numeric id and a Map)?
>>
>> I see the technique you used in IMP++ ("storing" the previous environment
>> in the computation and then restoring it after the content of the block
>> has been executed). It looks great, but in my case I sometimes need access
>> to at least the "global" environment (the first that was stored stored),
>> and I don't see how to do it in that case (that's why I'm considering
>> using a list).
>>
>> Btw, I'm finding K very stimulating.
>>
>> Regards,
>> Daniele
>> _______________________________________________
>> k-user mailing list
>> k-user AT cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/k-user






Archive powered by MHonArc 2.6.16.

Top of Page