Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Knuth-shuffle/Elena/knuth-shuffle.elena
Normal file
28
Task/Knuth-shuffle/Elena/knuth-shuffle.elena
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import system'routines;
|
||||
import extensions;
|
||||
|
||||
const int MAX = 10;
|
||||
|
||||
extension randomOp
|
||||
{
|
||||
randomize()
|
||||
{
|
||||
var max := self.Length;
|
||||
|
||||
for(int i := 0, i < max, i += 1)
|
||||
{
|
||||
var j := randomGenerator.eval(i,max);
|
||||
|
||||
self.exchange(i,j)
|
||||
};
|
||||
|
||||
^ self
|
||||
}
|
||||
}
|
||||
|
||||
public program()
|
||||
{
|
||||
var a := Array.allocate:MAX.populate:(i => i );
|
||||
|
||||
console.printLine(a.randomize())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue