@@ -3132,14 +3132,16 @@ def rand_look(*args)
3132
3132
3133
3133
Does not consume a random value from the stream. Therefore, multiple sequential calls to `rand_look` will all return the same value." ,
3134
3134
examples : [ "
3135
- print rand_look(0.5) #=> will print a number like 0.375030517578125 to the output pane",
3135
+ print rand_look(0.5) # will print a number like 0.375030517578125 to the output pane" ,
3136
3136
3137
3137
"
3138
- print rand_look(0.5) #=> will print a number like 0.375030517578125 to the output pane
3139
- print rand_look(0.5) #=> will print the same number again
3140
- print rand_look(0.5) #=> will print the same number again
3141
- print rand(0.5) #=> will print a different random number
3142
- print rand_look(0.5) #=> will print the same number as the previous line again."
3138
+ print rand_look(0.5) # will print a number like 0.375030517578125 to the output pane
3139
+ print rand_look(0.5) # will print the same number again
3140
+ print rand_look(0.5) # will print the same number again
3141
+ print rand(0.5) # will still print the same number again
3142
+ # (this is the number rand_look was 'looking ahead' at)
3143
+ # the number is now consumed
3144
+ print rand_look(0.5) # will print a new number like 0.3669586181640625 to the output pane"
3143
3145
]
3144
3146
3145
3147
@@ -3160,14 +3162,16 @@ def rand_i_look(*args)
3160
3162
3161
3163
Does not consume a random value from the stream. Therefore, multiple sequential calls to `rand_i_look` will all return the same value." ,
3162
3164
examples : [ "
3163
- print rand_i_look(5) #=> will print either 0, 1, 2, 3, or 4 to the output pane" ,
3165
+ print rand_i_look(5) # will print either 0, 1, 2, 3, or 4 to the output pane" ,
3164
3166
3165
3167
"
3166
- print rand_i_look(5) #=> will print either 0, 1, 2, 3, or 4 to the output pane
3167
- print rand_i_look(5) #=> will print the same number again
3168
- print rand_i_look(5) #=> will print the same number again
3169
- print rand_i(5) #=> will print either 0, 1, 2, 3, or 4 to the output pane
3170
- print rand_i_look(5) #=> will print the same number as the previous statement"
3168
+ print rand_i_look(5) # will print either 0, 1, 2, 3, or 4 to the output pane
3169
+ print rand_i_look(5) # will print the same number again
3170
+ print rand_i_look(5) # will print the same number again
3171
+ print rand_i(5) # will still print the same number again
3172
+ # (this is the number rand_i_look was 'looking ahead' at)
3173
+ # the number is now consumed
3174
+ print rand_i_look(5) # will print either 0, 1, 2, 3, or 4 to the output pane"
3171
3175
]
3172
3176
3173
3177
@@ -3315,9 +3319,9 @@ def use_random_seed(seed, &block)
3315
3319
## Basic usage
3316
3320
3317
3321
use_random_seed 1 # reset random seed to 1
3318
- puts rand # => 0.417022004702574
3322
+ puts rand # => 0.733917236328125
3319
3323
use_random_seed 1 # reset random seed back to 1
3320
- puts rand #=> 0.417022004702574
3324
+ puts rand #=> 0.733917236328125
3321
3325
" ,
3322
3326
"
3323
3327
## Generating melodies
@@ -3372,15 +3376,15 @@ def with_random_seed(seed, &block)
3372
3376
requires_block : true ,
3373
3377
examples : [ "
3374
3378
use_random_seed 1 # reset random seed to 1
3375
- puts rand # => 0.417022004702574
3376
- puts rand #=> 0.7203244934421581
3379
+ puts rand # => 0.733917236328125
3380
+ puts rand #=> 0.464202880859375
3377
3381
use_random_seed 1 # reset it back to 1
3378
- puts rand # => 0.417022004702574
3382
+ puts rand # => 0.733917236328125
3379
3383
with_random_seed 1 do # reset seed back to 1 just for this block
3380
- puts rand # => 0.417022004702574
3381
- puts rand #=> 0.7203244934421581
3384
+ puts rand # => 0.733917236328125
3385
+ puts rand #=> 0.464202880859375
3382
3386
end
3383
- puts rand # => 0.7203244934421581
3387
+ puts rand # => 0.464202880859375
3384
3388
# notice how the original generator is restored" ,
3385
3389
"
3386
3390
## Generating melodies
0 commit comments