Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Knuth-shuffle/Joy/knuth-shuffle-1.joy
Normal file
12
Task/Knuth-shuffle/Joy/knuth-shuffle-1.joy
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
DEFINE knuth-shuffle ==
|
||||
(* Take the size of the array (without destroying it) *)
|
||||
dup dup size
|
||||
(* Generate a list of as many random numbers *)
|
||||
[rand] [rem] enconcat map
|
||||
(* Zip the two lists *)
|
||||
swap zip
|
||||
(* Sort according to the new index number *)
|
||||
[small] [] [uncons unswonsd [first >] split [swons] dip2]
|
||||
[enconcat] binrec
|
||||
(* Delete the new index number *)
|
||||
[second] map.
|
||||
3
Task/Knuth-shuffle/Joy/knuth-shuffle-2.joy
Normal file
3
Task/Knuth-shuffle/Joy/knuth-shuffle-2.joy
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(* Sorted array of 21 integers *)
|
||||
[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
|
||||
knuth-shuffle.
|
||||
Loading…
Add table
Add a link
Reference in a new issue