Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,12 @@
|
|||
import Control.Monad
|
||||
|
||||
permutationSort l = head [p | p <- permute l, sorted p]
|
||||
|
||||
sorted (e1 : e2 : r) = e1 <= e2 && sorted (e2 : r)
|
||||
sorted _ = True
|
||||
|
||||
permute = foldM (flip insert) []
|
||||
|
||||
insert e [] = return [e]
|
||||
insert e l@(h : t) = return (e : l) `mplus`
|
||||
do { t' <- insert e t ; return (h : t') }
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import Data.List (permutations)
|
||||
|
||||
permutationSort l = head [p | p <- permutations l, sorted p]
|
||||
|
||||
sorted (e1 : e2 : r) = e1 <= e2 && sorted (e2 : r)
|
||||
sorted _ = True
|
||||
Loading…
Add table
Add a link
Reference in a new issue