Linear congruential generator: Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: changed a comment, added vertical whitespace.)
(Add Factor)
Line 1,475: Line 1,475:
val MS : int list =
val MS : int list =
[38; 7719; 21238; 2437; 8855; 11797; 8365; 32285; 10450; 30612]</pre>
[38; 7719; 21238; 2437; 8855; 11797; 8365; 32285; 10450; 30612]</pre>

=={{header|Factor}}==
{{works with|Factor|0.98}}
<lang factor>USING: fry io kernel lists lists.lazy math prettyprint ;

: lcg ( seed a c m quot: ( state -- rand ) -- list )
[ '[ _ * _ + _ mod ] lfrom-by ] [ lmap-lazy cdr ] bi* ; inline

0 1103515245 12345 2147483648 [ ] lcg ! bsd
0 214013 2531011 2147483648 [ -16 shift ] lcg ! ms
[ 10 swap ltake [ . ] leach nl ] bi@</lang>
{{out}}
<pre>
12345
1406932606
654583775
1449466924
229283573
1109335178
1051550459
1293799192
794471793
551188310

38
7719
21238
2437
8855
11797
8365
32285
10450
30612
</pre>


=={{header|Forth}}==
=={{header|Forth}}==