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

Add Random class with seed support. #1540

Merged
merged 1 commit into from Jul 22, 2016
Merged

Conversation

iliabylich
Copy link
Contributor

Modified random-based core methods to use Random:

opal-repl
>> srand(10); 1.upto(10).to_a.shuffle
=> [4, 1, 2, 3, 7, 8, 6, 5, 9, 10]
>> srand(10); 1.upto(10).to_a.shuffle
=> [4, 1, 2, 3, 7, 8, 6, 5, 9, 10]
>> srand(20); 1.upto(10).to_a.shuffle
=> [1, 6, 8, 5, 7, 4, 10, 2, 3, 9]
>> srand(20); 1.upto(10).to_a.shuffle
=> [1, 6, 8, 5, 7, 4, 10, 2, 3, 9]

@elia
Copy link
Member

elia commented Jul 22, 2016

@iliabylich 👍🏼 to merge, you had a look to #657 also?

@iliabylich
Copy link
Contributor Author

@elia Yeah, I've extracted some code from those PR 😄 But it was easier to rewrite everything (since it's outdated) and use some simple random generator.

@iliabylich iliabylich merged commit 0c91c71 into opal:master Jul 22, 2016
@iliabylich iliabylich deleted the add-random branch October 6, 2016 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants