all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,7 @@
|
|||
bsort :: Ord a => [a] -> [a]
|
||||
bsort s = case _bsort s of
|
||||
t | t == s -> t
|
||||
| otherwise -> bsort t
|
||||
where _bsort (x:x2:xs) | x > x2 = x2:(_bsort (x:xs))
|
||||
| otherwise = x:(_bsort (x2:xs))
|
||||
_bsort s = s
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import Data.Maybe (fromMaybe)
|
||||
import Control.Monad
|
||||
|
||||
bsort :: Ord a => [a] -> [a]
|
||||
bsort s = maybe s bsort $ _bsort s
|
||||
where _bsort (x:x2:xs) = if x > x2
|
||||
then Just $ x2 : fromMaybe (x:xs) (_bsort $ x:xs)
|
||||
else liftM (x:) $ _bsort (x2:xs)
|
||||
_bsort _ = Nothing
|
||||
Loading…
Add table
Add a link
Reference in a new issue