Nhc98

From HaskellWiki
uncommon :: [Int]->[Int]->[Int]
uncommon x y=common (finalsort (x++y))

common :: [Int]->[Int]
common []=[]
common [x]=[x]
common (x:y:zs)
 | (x==y) =common zs
 | otherwise =x:(common (y:zs))

sort :: [Int]->[Int]->[Int]
sort [] x=x
sort x []=x
sort (x:xs) (y:ys)
 | (x>=y) =x:(sort xs (y:ys))
 | otherwise =y:(sort (x:xs) ys)

finalsort :: [Int]->[Int]
finalsort [x]=[x]
finalsort x=sort (finalsort (first x)) (finalsort (lastest x))

mylength :: [Int]->Int
mylength []=0
mylength (x:xs)=1+ mylength xs

auxfirst :: [Int]->Int->[Int]
auxfirst x 0=[]
auxfirst (y:ys) x=y:(auxfirst ys (x-1))

first :: [Int]->[Int]
first x=auxfirst x (div (mylength x) 2)

auxlast :: [Int]->Int->[Int]
auxlast x 0=x
auxlast (x:xs) y=auxlast xs (y-1)

lastest :: [Int]->[Int]
lastest x=auxlast x (div (mylength x) 2)