all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 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