Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a random generator in TCL/Tk?

Status
Not open for further replies.

Wintercloak

Programmer
Feb 25, 2003
4
SE
I have been looking for a random generator in TCL/Tk but I cant find anyone.
Is there other packages that provide one or is it possible to call for the C-functions: seed() and rand()?

 
rand() is what you want.

example:
proc foo {} {
set curr 0
set max 12000
while {$curr < $max} {
set curr [expr int(1 + rand() * [expr $max * 2])]
}
puts &quot;$curr&quot;
}
 
Oh, rand() is &quot;hidden&quot; in expr.
Thank you very much.

...games without random numbers are boring 8)

/Wintercloak
 
Yep, I wouldn't play many of them that kept
giving me 1's on all my dice rolls. ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top