k-user AT lists.cs.illinois.edu
Subject: K-user mailing list
List archive
- From: Abdul Dakkak <abduld AT wolfram.com>
- To: Traian Florin Șerbănuță <traian.serbanuta AT info.uaic.ro>
- Cc: k-user <k-user AT cs.uiuc.edu>
- Subject: Re: [K-user] Printing K terms to stdout
- Date: Thu, 13 Dec 2012 15:45:40 -0600 (CST)
- List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
- List-id: <k-user.cs.uiuc.edu>
Ok, so 2 things, I needed the [function] and my previous definition defined
toString as an Exp
syntax Exp ::= "toString" "(" Value ")" [function]
changing that to a Value (what KResult is set to) makes the print statements
works. for example
$ cat primitive.rb
puts(nil);
puts(1);
puts(true);
puts(!true);
puts("hello k");
$ krun --no-config primitive.rb
nil
1
true
false
hello k
thanks traian
-adk-
----- Original Message -----
> From: "Traian Florin Șerbănuță"
> <traian.serbanuta AT info.uaic.ro>
> To: "Abdul Dakkak"
> <abduld AT wolfram.com>
> Cc: "k-user"
> <k-user AT cs.uiuc.edu>
> Sent: Thursday, December 13, 2012 2:34:04 PM
> Subject: Re: [K-user] Printing K terms to stdout
>
> When you declared toString, did you annotated it with [function]?
> If not, the tool would only evaluate it when at the top of the K
> cell.
>
>
> This would explain why it is not evaluated in the ListItem.
>
>
> hope that helps.
>
>
> best wishes,
> - traian
>
>
>
> 2012/12/13 Abdul Dakkak <
> abduld AT wolfram.com
> >
>
>
>
>
> Is there a way to print things that are not ints or strings to
> stdout. In kool, for example, print(true) does not print to stdout.
> It gets placed in the out cell as ListItem(true), but I would like
> it to print. I even tried the following:
>
>
> rule toString(nil) => "nil"
> rule toString(true) => "true"
> rule toString(false) => "false"
> rule toString(I:Int) => Int2String(I)
> rule toString(S:String) => S
>
> rule <k> puts(V:Value, Vs => Vs) ; ...</k>
> <out>... . => ListItem(toString(V)) </out> [print]
> rule <k> puts(.Exps) ; => . ...</k>
> <out>... . => ListItem("\n") </out> [structural, print]
>
>
> but that places ListItem(toString(true)) in the out cell. The out
> cell is defined as
>
> <out color="brown" stream="stdout"> .List </out>
>
> thanks for the help
>
> _______________________________________________
> k-user mailing list
> k-user AT cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/k-user
>
>
- [K-user] Printing K terms to stdout, Abdul Dakkak, 12/13/2012
- Re: [K-user] Printing K terms to stdout, Traian Florin Șerbănuță, 12/13/2012
- Re: [K-user] Printing K terms to stdout, Abdul Dakkak, 12/13/2012
- Re: [K-user] Printing K terms to stdout, Traian Florin Șerbănuță, 12/13/2012
Archive powered by MHonArc 2.6.16.