30 lines
662 B
Text
30 lines
662 B
Text
; Configuration parameters for Microsoft and BSD implementations
|
|
make "LCG_MS [214013 2531011 65536 2147483648]
|
|
make "LCG_BSD [1103515245 12345 1 2147483648]
|
|
|
|
; Default seed is 0
|
|
make "_lcg_value 0
|
|
|
|
; set the seed
|
|
to lcg_seed :seed
|
|
make "_lcg_value :seed
|
|
end
|
|
|
|
; generate the next number in the series using the given parameters
|
|
to lcg_rand [:config :LCG_MS]
|
|
local "a local "c local "d local "m
|
|
foreach [a c d m] [
|
|
make ? item # :config
|
|
]
|
|
make "_lcg_value (modulo (sum (product :a :_lcg_value) :c) :m)
|
|
output int quotient :_lcg_value :d
|
|
end
|
|
|
|
foreach (list :LCG_BSD :LCG_MS) [
|
|
lcg_seed 0
|
|
repeat 10 [
|
|
print (lcg_rand ?)
|
|
]
|
|
print []
|
|
]
|
|
bye
|