Skip to Content.
Sympa Menu

k-user - Re: [K-user] Condition: Not-empty List

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] Condition: Not-empty List


Chronological Thread 
  • From: Radu Mereuta <headness13 AT gmail.com>
  • To: Omar Duhaiby <3omarz AT gmail.com>
  • Cc: "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>
  • Subject: Re: [K-user] Condition: Not-empty List
  • Date: Mon, 12 May 2014 11:00:22 -0500
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

Hi Omar,

At the moment List is a disjoint sort form user syntax.
You will have to wrap all your elements with ListItem( 'element' ). That is if you want to use the sort List.
But you can use your own type of lists in a cell:

syntax Vals ::= List{Val,","}
configuration <myCell> .Vals </myCell>
rule <myCell> _:Vals => .Vals </myCell>

At the moment the only thing you are gaining by using the sort List, is associative matching.
All user defined lists, are cons lists.

Hope this helps you,
Radu
K dev



On Sun, May 11, 2014 at 9:30 AM, Omar Duhaiby <3omarz AT gmail.com> wrote:
Hello,

If I have defined Vals as:

syntax Vals ::= List{Val, ","}
syntax Val ::= Int

and I have a cell initiated with ".List" that I want to hold Vals.
".List" is matched when the list is empty, but how do I check if the cell is not empty, i.e., the list has at least one Val?

Also I want to be able to initiate the cell with .Vals instead of .List but the compile refuses.

Thank you

_______________________________________________
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