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: David Lazar <lazar6 AT illinois.edu>
  • To: Daniele Filaretti <dfilaretti AT gmail.com>
  • Cc: k-user AT cs.uiuc.edu
  • Subject: Re: [K-user] List of Maps: possible?
  • Date: Mon, 30 Jul 2012 23:44:58 -0500
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user>
  • List-id: <k-user.cs.uiuc.edu>

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