Anonymous user
Sorting algorithms/Permutation sort: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 115:
| h :: t as l -> (e :: l) :: List.map (fun t' -> h :: t') (insert e t)
let permute xs = List.fold_right (fun h z -> List.concat (List.map (insert h) z))
let permutation_sort l = List.find sorted (permute l)</lang>
Line 133 ⟶ 132:
=={{header|Python}}==
{{works with|Python|2.6}}
<lang python>from itertools import permutations
in_order = lambda s: all(x <= s[i+1] for i,x in enumerate(s[:-1]))
|