Issue 89 in partcl: Implement srand() and rand()

3 views
Skip to first unread message

codesite...@google.com

unread,
Oct 12, 2009, 1:42:27 PM10/12/09
to partc...@googlegroups.com

Comment #3 on issue 89 by wcoleda: Implement srand() and rand()
http://code.google.com/p/partcl/issues/detail?id=89

http://www.tcl.tk/man/tcl8.5/TclCmd/mathfunc.htm describes these functions.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

codesite...@google.com

unread,
Oct 12, 2009, 1:46:42 PM10/12/09
to partc...@googlegroups.com

Comment #4 on issue 89 by wcoleda: Implement srand() and rand()
http://code.google.com/p/partcl/issues/detail?id=89

Here's some output from an 8.5 tclsh:

$ tclsh8.5
% expr rand()
0.5210889827092593
% expr srand()
too few arguments for math function "srand"
% expr srand(3.2)
expected integer but got "3.2"
% expr srand("whee")
expected integer but got "whee"
% expr rand(1,2,3)
too many arguments for math function "rand"
% expr srand(1,2)
too many arguments for math function "srand"
% expr srand(1)
7.826369259425611e-6

to convert an arbitrary argument to an integer, use the 'toInteger' helper
sub. It
should throw the appropriate error if given an invalid value. tests for
expr are in
t/cmd_expr.t (and are written in Tcl)

codesite...@google.com

unread,
Oct 12, 2009, 1:50:54 PM10/12/09
to partc...@googlegroups.com

Comment #5 on issue 89 by wcoleda: Implement srand() and rand()
http://code.google.com/p/partcl/issues/detail?id=89

(Right now the too few/too many errors are handled via the pge/ast/pir
transform, so
you don't need to handle that in the .sub definition itself.)

Reply all
Reply to author
Forward
0 new messages