ldevillez

Shuffle

Nov 18th, 2016
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Oz 0.45 KB | None | 0 0
  1.    if L == nil then nil
  2.    else
  3.       local Length A L2 in
  4.      {List.length L Length}
  5.      A = {NewArray 1 Length 0}
  6.      L2 = {NewCell nil}
  7.  
  8.      for J in 1..Length do
  9.         local Na in
  10.         {List.nth L J Na}
  11.            A.J := Na
  12.         end
  13.      end
  14.      
  15.      for J2 in 1..Length do
  16.         local I J in
  17.            J = Length + 1 - J2
  18.            I = {Number.abs ({OS.rand} mod J) } + 1
  19.            L2 := A.I|@L2
  20.            A.I := A.J
  21.         end
  22.      end
  23.      
  24.      @L2
  25.       end
  26.    end
Add Comment
Please, Sign In to add comment