Skip to Content.
Sympa Menu

k-user - Re: [K-user] (no subject)

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] (no subject)


Chronological Thread 
  • From: Chris Hathhorn <chathhorn AT gmail.com>
  • To: Ömer Sinan Ağacan <omeragacan AT gmail.com>
  • Cc: k-user AT cs.uiuc.edu
  • Subject: Re: [K-user] (no subject)
  • Date: Sun, 18 Aug 2013 17:35:20 -0500
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

On Sun, Aug 18, 2013 at 5:22 PM, Ömer Sinan Ağacan
<omeragacan AT gmail.com>
wrote:
> Thanks Chris, your solution worked(with a minor change, I had to add
> `...` after `rule incSomeMap(.Set, _) => .`).
>
> In your code, what's happening here:
>
> incSomeMap((SetItem(K:K) => .Set) _:Set, I:Int) ...
>
> ? As far as I can understand `SetItem(K:K) => .Set)` matches an
> element of the set and replaces with unit(effectively removing the
> element), but what is that _ after this? eg. _:Set ? My guess is that
> _ unifies with rest of the set, is that correct? I think this is the
> first time I'm seeing this syntax. Is there also similar syntax to
> match match first element/rest of a map too?
>

Yeah that's right. The "_:Set" matches the rest of the set (actually
it should also work without the ":Set" and with "." for ".Set"). For
maps from K to Int, you could use "(K:K |-> I:Int => .) _" to peel off
the first key/value pair from a map.

Chris





Archive powered by MHonArc 2.6.16.

Top of Page