September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,49 +1,49 @@
#import system.
#import system'dynamic.
#import extensions.
#import system'routines.
#import system'collections.
import system'dynamic.
import extensions.
import system'routines.
import system'collections.
#class(extension)algorithmOp
extension algorithmOp
{
#method s_of_n
s_of_n
[
#var counter := Integer new.
var counter := Integer new.
var n := self.
^ ArrayList new mix &into:
^ ArrayList new; mixInto:
{
eval : n
eval : i
[
counter += 1.
counter append:1.
(this length < self)
? [ this += n. ]
! [
(randomGenerator eval:counter < self)
? [ this@(randomGenerator eval:self) := n. ].
if (self length < n)
[ self append:i ];
[
if(randomGenerator eval:counter < n)
[ self[randomGenerator eval:n] := i ].
].
^ this array.
^ self array
]
}.
]
}
#symbol program =
program =
[
#var bin := Array new:10 set &every:(&index:n) [ Integer new ].
0 till:10000 &doEach: trial
var bin := Array new:10; populate(:n)( Integer new ).
0 till:10000 do(:trial)
[
#var s_of_n := 3 s_of_n.
var s_of_n := 3 s_of_n.
0 till:10 &doEach:n
0 till:10 do(:n)
[
#var sample := s_of_n eval:n.
var sample := s_of_n eval:n.
(n == 9)
? [ sample run &each: i [ bin@i += 1. ]. ].
].
if (n == 9)
[ sample forEach(:i) [ bin[i] append:1 ] ]
]
].
console writeLine:bin.
console printLine:bin; readChar.
].