Skip to Content.
Sympa Menu

k-user - Re: [K-user] Our Experience Hacking a JS model in K (Robby Findler)

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] Our Experience Hacking a JS model in K (Robby Findler)


Chronological Thread 
  • From: Radu Mereuta <headness13 AT gmail.com>
  • To: Daniele Filaretti <dfilaretti AT gmail.com>
  • Cc: k-user AT cs.uiuc.edu
  • Subject: Re: [K-user] Our Experience Hacking a JS model in K (Robby Findler)
  • Date: Tue, 11 Dec 2012 13:04:44 +0200
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

Hi Daniele,

Regarding the Map question. The Map sort is an AC list as in maude. That means that elements don't have a specific order (at least theoretically). In practice maude arranges those elements for faster matching, but I wouldn't rely on that.
What you could do is to store your keys in an Associative list (like a cell of type List), order them and then iterate over those elements and just pull the objects from the map. That could be one way of doing it.

Radu Mereuta
K Developer

On Tue, Dec 11, 2012 at 12:26 PM, Daniele Filaretti <dfilaretti AT gmail.com> wrote:
On 10 Dec 2012, at 21:40, k-user-request AT cs.uiuc.edu wrote:

I believe the real problem here is the lack of a reference manual for
the language. There is a lot of tutorial information (and that kind of
documentation is important and very helpful) but when you want to head
off on your own, you need to understand what the basic building blocks
of the language are and what the legal combinations of them in a more
systematic manner.

Hi, 
I just wanted to say that I perfectly agree! 
The tutorials are absolutely great (thanks to the tutorials I started using K), but at some point a manual would be better for experienced users. 
In particular, it would be very useful to have a reference of all the built in data structures (lists, maps etc.) and the operations that one can perform on them.

Along these lines I'd say that we definitely
understood the => and ... operators and how they interact with the
cells, but we failed to understand what's really going on with sets vs
cons-lists vs associative-lists and when we had which of those.

By the way, does anybody know if there is a built in "ordered map" data structure in K? 
I need something like that, let say a map from some keys to some values, but it has to be ordered. I noticed that the K Maps are ordered in lexicographic order, and it seems there is no last element (they are kind of cyclic). 
So I've tried to do the same with a list of pairs but in that way I loose uniqueness of the keys.
Someone recently suggested another solution to me, using a map from natural numbers to key-value pairs… 

Cheers, 
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