Anonymous user
Knuth's algorithm S: Difference between revisions
→{{header|Elena}}
m (→{{header|J}}) |
|||
Line 556:
=={{header|Elena}}==
<lang elena>#import system'dynamic.
#import extensions.
#import system'routines.
#import system'collections.
{
[
var n := self.
^ ArrayList new mix &into:
{
eval :
[
counter += 1.
if (
((randomGenerator eval:counter <
? [
].
^
]
}.
Line 587:
}
[
0 till:10000 &doEach: trial
[
0 till:10 &doEach:n
[
if (n == 9)
].
].
console writeLine:bin readChar.
].</lang>
{{out}}
|