Skip to Content.
Sympa Menu

k-user - Re: [K-user] concrete syntax for maps?

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] concrete syntax for maps?


Chronological Thread 
  • From: "Guth, Dwight" <dguth2 AT illinois.edu>
  • To: Robby Findler <robby AT eecs.northwestern.edu>, "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>
  • Subject: Re: [K-user] concrete syntax for maps?
  • Date: Thu, 1 Nov 2012 22:25:14 +0000
  • Accept-language: en-US
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

Well, the lists you get from doing what you describe are of sort K rather than the actual lists of sort List which are associative. But you can do what I did for python :

syntax KeyDatum ::= Exp ":" Exp
syntax KeyData ::= List{KeyDatum, ","}

rule mapify(a : b,  c) => a |-> b mapify(c)

rule mapify(.KeyData) => .Map

Actually using "|->" might be tricky though : not sure, never tried it.

Robby Findler <robby AT eecs.northwestern.edu> wrote:

Is there a way to write down a map as part of an input program, in a way sort of like how one can write down lists? That is, I can write 

    syntax LoS ::= List{Sting,","}
 
somewhere in a program and then I can write

  "a","b","c"

in a program somewhere and get a list. I'd like to write something like:

    syntax MoS ::= Map{Sting,"|->",","}

and then I can write:

  "a" |-> 0, "b" |-> 1

and have that come out as a K map?

Robby




Archive powered by MHonArc 2.6.16.

Top of Page