Advertisement
PonaFly

Untitled

Nov 4th, 2016
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- 4
  2. ntoList  :: Integer -> [Integer] -> [Integer]
  3. ntoList n l | (n == 0) = (reverse (filter even l))
  4.             | otherwise = ntoList (div n 10) ( (mod n 10) : l )
  5.            
  6. listtoN :: [Integer] -> Integer
  7. listtoN l = foldl (\x y -> x*10 + y ) 0 l
  8.  
  9.  
  10. strangeCompare :: Integer -> Integer -> Ordering
  11. strangeCompare a b = compare (listtoN (ntoList a [0])) (listtoN (ntoList b [0]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement