|
|
Line 90: |
Line 90: |
|
{{out}} |
|
{{out}} |
|
<pre>220 197 147 174 117 97 149 171 240 241</pre> |
|
<pre>220 197 147 174 117 97 149 171 240 241</pre> |
|
|
|
⚫ |
|
|
⚫ |
ca is a cellular automata class. The rng class inherits ca and extends it with bit and byte verbs to sample the ca. |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
DOC =: 'locale creation: (RULE ; INITIAL_STATE) conew ''ca''' |
|
⚫ |
create =: 3 :'''RULE STATE'' =: y' |
|
⚫ |
next =: 3 :'STATE =: RULE (((8$2) #: [) {~ [: #. [: -. [: |: |.~"1 0&_1 0 1@]) STATE' |
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
bit =: 3 :'([ next) ({. STATE)' |
|
⚫ |
byte =: [: #. [: , [: bit"0 (i.8)"_ |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
Having installed these into a j session we create and use the mathematica prng. |
|
⚫ |
|
|
⚫ |
m =: (30 ; 64 {. 1) conew 'rng' |
|
⚫ |
|
|
⚫ |
220 197 147 174 117 97 149 171 100 151 |
|
⚫ |
|
|
|
|
|
|
|
=={{header|D}}== |
|
=={{header|D}}== |
Line 172: |
Line 150: |
|
44</pre> |
|
44</pre> |
|
Run-time: less than two seconds with the ldc2 compiler. |
|
Run-time: less than two seconds with the ldc2 compiler. |
|
|
|
|
⚫ |
|
|
⚫ |
ca is a cellular automata class. The rng class inherits ca and extends it with bit and byte verbs to sample the ca. |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
DOC =: 'locale creation: (RULE ; INITIAL_STATE) conew ''ca''' |
|
⚫ |
create =: 3 :'''RULE STATE'' =: y' |
|
⚫ |
next =: 3 :'STATE =: RULE (((8$2) #: [) {~ [: #. [: -. [: |: |.~"1 0&_1 0 1@]) STATE' |
|
⚫ |
|
|
|
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
bit =: 3 :'([ next) ({. STATE)' |
|
⚫ |
byte =: [: #. [: , [: bit"0 (i.8)"_ |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
Having installed these into a j session we create and use the mathematica prng. |
|
⚫ |
|
|
⚫ |
m =: (30 ; 64 {. 1) conew 'rng' |
|
⚫ |
|
|
⚫ |
220 197 147 174 117 97 149 171 100 151 |
|
⚫ |
|
|
|
|
|
|
=={{header|Perl}}== |
|
=={{header|Perl}}== |