September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1,49 +1,52 @@
|
|||
import system'dynamic.
|
||||
import extensions.
|
||||
import system'routines.
|
||||
import system'collections.
|
||||
import system'dynamic;
|
||||
import extensions;
|
||||
import system'routines;
|
||||
import system'collections;
|
||||
|
||||
extension algorithmOp
|
||||
{
|
||||
s_of_n
|
||||
[
|
||||
var counter := Integer new.
|
||||
var n := self.
|
||||
s_of_n()
|
||||
{
|
||||
var counter := new Integer();
|
||||
var n := self;
|
||||
|
||||
^ ArrayList new; mixInto:
|
||||
^ new ArrayList().mixInto(
|
||||
{
|
||||
eval(i)
|
||||
{
|
||||
eval : i
|
||||
[
|
||||
counter append:1.
|
||||
counter.append:1;
|
||||
|
||||
if (self length < n)
|
||||
[ self append:i ];
|
||||
[
|
||||
if(randomGenerator eval:counter < n)
|
||||
[ self[randomGenerator eval:n] := i ].
|
||||
].
|
||||
if (__target.Length < n)
|
||||
{
|
||||
__target.append:i
|
||||
}
|
||||
else
|
||||
{
|
||||
if(randomGenerator.nextInt:counter < n)
|
||||
{ __target[randomGenerator.nextInt:n] := i }
|
||||
};
|
||||
|
||||
^ self array
|
||||
]
|
||||
}.
|
||||
]
|
||||
^ __target.Value
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
program =
|
||||
[
|
||||
var bin := Array new:10; populate(:n)( Integer new ).
|
||||
0 till:10000 do(:trial)
|
||||
[
|
||||
var s_of_n := 3 s_of_n.
|
||||
public program()
|
||||
{
|
||||
var bin := Array.allocate(10).populate:(n => new Integer());
|
||||
for(int trial := 0, trial < 10000, trial += 1)
|
||||
{
|
||||
var s_of_n := 3.s_of_n();
|
||||
|
||||
0 till:10 do(:n)
|
||||
[
|
||||
var sample := s_of_n eval:n.
|
||||
for(int n := 0, n < 10, n += 1)
|
||||
{
|
||||
var sample := s_of_n.eval:n;
|
||||
|
||||
if (n == 9)
|
||||
[ sample forEach(:i) [ bin[i] append:1 ] ]
|
||||
]
|
||||
].
|
||||
{ sample.forEach:(i){ bin[i].append:1 } }
|
||||
}
|
||||
};
|
||||
|
||||
console printLine:bin; readChar.
|
||||
].
|
||||
console.printLine:bin.readChar()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue