k-user AT lists.cs.illinois.edu
Subject: K-user mailing list
List archive
- 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 18:16:00 -0500
- List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
- List-id: <k-user.cs.uiuc.edu>
That's the expected behavior.
Since 'List' and Vals are disjoint, you can't do that. The type checker from the parser complains.
The second version also violates the type system.
syntax Vals ::= List{Val,","}
actually stands for (cons list):
syntax Vals ::= Val "," Vals | ".Vals"
And by that rule, I think that you mean:
<myCell> V:Val, Vs:Vals => Vs </myCell>
That's closer to the typical way you could evaluate parameters given to a function. (check simple-untyped example from the k distribution)
Radu
On Mon, May 12, 2014 at 12:01 PM, Omar Duhaiby <3omarz AT gmail.com> wrote:
Thank you Radu, but I actually tried doing that in the configuration: <myCell> .Vals </myCell>.
But when I do <myCell>... . => ListItem(V) </myCell> , the compiler refuses saying:
Critical: Wrong type in cell 'myCell'. Expected sort: K but found Listand when I do <myCell> Vs:Vals => Vs, V </myCell>, I get:
Critical: type error: unexpected term 'Vs:Vals ' of sort 'Vals', expected sort 'Val'.On Mon, May 12, 2014 at 7:00 PM, Radu Mereuta <headness13 AT gmail.com> wrote:
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,RaduK devOn Sun, May 11, 2014 at 9:30 AM, Omar Duhaiby <3omarz AT gmail.com> wrote:
_______________________________________________".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?and I have a cell initiated with ".List" that I want to hold Vals.syntax Val ::= Intsyntax Vals ::= List{Val, ","}Hello,If I have defined Vals as:
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
- [K-user] Condition: Not-empty List, Omar Duhaiby, 05/11/2014
- Re: [K-user] Condition: Not-empty List, Radu Mereuta, 05/12/2014
- Re: [K-user] Condition: Not-empty List, Omar Duhaiby, 05/12/2014
- Re: [K-user] Condition: Not-empty List, Radu Mereuta, 05/12/2014
- Re: [K-user] Condition: Not-empty List, Omar Duhaiby, 05/12/2014
- Re: [K-user] Condition: Not-empty List, Radu Mereuta, 05/12/2014
Archive powered by MHonArc 2.6.16.