Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turns out seedRandom doesn't work on unix platforms. This fixes that #2

Merged
2 commits merged into from
Jan 11, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib-clay/random/platform/platform.unix.clay
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ random() {
return UInt(libc.random());
}

seedRandom(x:Int) {
libc.srandom(UInt(x));
seedRandom(x:UInt) {
libc.srandom(x);
}

seedRandomWithTime() {
var t = unix.time(null(CLong));
seedRandom(Int(t));
seedRandom(UInt(t));
}
1 change: 1 addition & 0 deletions test/random.clay
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import random;

main() {
random.seedRandom();
random.seedRandom(42);
while (true) {
var x = random.randomInt(20);
println(x);
Expand Down