Skip to Content.
Sympa Menu

k-user - Re: [K-user] Printing K terms to stdout

k-user AT lists.cs.illinois.edu

Subject: K-user mailing list

List archive

Re: [K-user] Printing K terms to stdout


Chronological Thread 
  • 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>
  • Subject: Re: [K-user] Printing K terms to stdout
  • Date: Thu, 13 Dec 2012 22:34:04 +0200
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/k-user/>
  • List-id: <k-user.cs.uiuc.edu>

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




Archive powered by MHonArc 2.6.16.

Top of Page