--- a/Random.st Fri Mar 02 14:15:56 2018 +0100
+++ b/Random.st Fri Mar 02 16:15:00 2018 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
======================================================================
|
@@ -549,6 +551,33 @@
"Modified: 1.4.1997 / 22:42:53 / cg"
!
+nextBytesNonZero:count
+ "return count random bytes, none of which is zero (i.e. 1..16rFF each)"
+
+ |res cnt "{Class: SmallInteger}"|
+
+ cnt := count.
+ res := ByteArray uninitializedNew:cnt.
+
+ 1 to:cnt do:[:i|
+ |nextNonZero|
+
+ [
+ self step.
+ (nextNonZero := seed bitAnd:16rFF) == 0
+ ] whileTrue.
+ res at:i put:nextNonZero.
+ ].
+
+ ^ res
+
+ "
+ Transcript showCR:(Random new nextBytesNonZero:20).
+ "
+
+ "Modified: 1.4.1997 / 22:42:53 / cg"
+!
+
nextCharacters:count
"get the next cnt printable characters.
We answer printable characters in the ascii range (codepoints 32 - 126)"