--- a/Random.st Fri Apr 27 15:13:16 2018 +0200
+++ b/Random.st Mon Apr 30 21:38:45 2018 +0200
@@ -428,6 +428,44 @@
"Modified: 1.4.1997 / 22:44:46 / cg"
!
+next:count
+ "return the next count random numbers in the range ]0..1["
+
+ |answerStream
+ cnt "{ Class: SmallInteger }" |
+
+ cnt := count.
+ answerStream := self contentsSpecies writeStream:cnt.
+ 1 to:cnt do:[:index | |next|
+ next := self next.
+ answerStream nextPut:next.
+ ].
+ ^ answerStream contents
+
+ "
+ (RandomGenerator new) next:10
+ "
+!
+
+next:count integerBetween:min and:max
+ "return the next count random integers in min..max"
+
+ |answerStream
+ cnt "{ Class: SmallInteger }" |
+
+ cnt := count.
+ answerStream := self contentsSpecies writeStream:cnt.
+ 1 to:cnt do:[:index | |next|
+ next := self nextIntegerBetween:min and:max.
+ answerStream nextPut:next.
+ ].
+ ^ answerStream contents
+
+ "
+ (RandomGenerator new) next:100 integerBetween:0 and:100
+ "
+!
+
nextBetween:start and:stop
"return a random number in the range ]start..stop[.
claus: the original GNU version has a bug in returning values