Skip to Content.
Sympa Menu

k-user - Re: [K-user] "not exist" condition

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] "not exist" condition


Chronological Thread 
  • From: Traian Florin Şerbănuţă <traian.serbanuta AT fmi.unibuc.ro>
  • To: Omar Duhaiby <3omarz AT gmail.com>
  • Cc: "k-user AT cs.uiuc.edu" <k-user AT cs.uiuc.edu>, Dwight Guth <dwight.guth AT gmail.com>, "Musab A. AlTurki" <musab AT kfupm.edu.sa>
  • Subject: Re: [K-user] "not exist" condition
  • Date: Wed, 5 Nov 2014 19:49:16 +0200
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

Yes, I think it should.

This would also work 
<flags> ListItem(_) ...</flags>

by matching one list item in the list, you ensure its non-emptyness.

best wishes,
Traian

2014-11-05 16:15 GMT+02:00 Omar Duhaiby <3omarz AT gmail.com>:
Thank you very much. One more question. Will the following work?
<flags> L:List </flags> when L =/=K .List
I want to make sure it is not an empty list.

On Wed, Nov 5, 2014 at 2:57 AM, Traian Florin Şerbănuţă <traian.serbanuta AT fmi.unibuc.ro> wrote:
Hi Omar,

One way which may work, although you may not like the solution, would be the following:

Use two cells, containing sets, one for set flags and one for unset flags
and have setting the flag move one element from unset to set and unsetting do the oposite.

rule <k> setFlag(N) => . ...</k> 
      <unsetFlags>... SetItem(N) => . ...</unsetFlags>   <setFlags>... . => SetItem(N) ...</setFlags>

Then you can check both which flags are set and which not by matching any of the cells or both.

rule <k> set12not3 => . ...</k>
   <setFlags>... SetItem(1) SetItem(2) ...</setFlags>   <unsetFlags>... SetItem(3) ...</unsetFlags>

Hope it helps,
Traian



2014-11-04 23:52 GMT+02:00 Omar Duhaiby <3omarz AT gmail.com>:
That's very useful. The 'if' condition comes right after specifying the cell and not at the end of the rule like 'when', right?

OK. suppose we made a cell in the configuration:
<flags> .List </flags>
and I mean to fill the list with Ints. I want to check if the list contains 1, and 2 and does not contain 3. How do I do that?


On Wed, Nov 5, 2014 at 12:33 AM, Mischael Schill <mischael.schill AT inf.ethz.ch> wrote:
I suppose you could do something like <flag> F </flag> if F =/=Int 1, but this only works if the flag cell exists and only contains integers.

Cheers,
Mischael Schill

Am 4. November 2014 22:28:05 MEZ, schrieb Omar Duhaiby <3omarz AT gmail.com>:
>Hello,
>
>Suppose I have a cell called 'flag' in my configuration next to the k
>cell.
>And I have the following rule:
>
>rule
><k> _ => . </k>
><flag> 1 </flag>
>
>This rule has one condition, that it has a value of 1 in the 'flag'
>cell.
>What if I want my condition to be: "flag has any value except one", or
>"there does not exist a value of 1 in the flag cell". Can I do that?
>
>Thank you
>Omar Alzuhaibi
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>k-user mailing list
>k-user AT cs.uiuc.edu
>http://lists.cs.uiuc.edu/mailman/listinfo/k-user



_______________________________________________
k-user mailing list
k-user AT cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/k-user




_______________________________________________
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