Guest User

Untitled

a guest
Apr 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import Data.Char
  2.  
  3. fix f = let x = f x in x
  4.  
  5. z = fix $ \z -> \f -> \la -> \lb ->
  6. case (f, la, lb) of
  7. (f, [], _) -> []
  8. (f, _, []) -> []
  9. (f, x:xs, y:ys) -> f x y : z f xs ys
  10.  
  11. m = fix $ \m -> \f -> \la ->
  12. case (f, la) of
  13. (f, []) -> []
  14. (f, x:xs) -> f x : m f xs
  15.  
  16. fl = fix $ \fl -> \l ->
  17. case l of
  18. ([]) -> []
  19. (([]:ls)) -> fl ls
  20. ((x:xs):ls) -> x : fl (xs : ls)
  21.  
  22. tk = fix $ \tk -> \i -> \l ->
  23. case (i, l) of
  24. (0, _) -> []
  25. (x, []) -> []
  26. (x, l:ls) -> l : tk (x - 1) ls
  27.  
  28. rep = \x -> let e = x : rep x in e
  29.  
  30. u = m chr $ z (+) (
  31. m (abs . (3-)) $ m ord $ fl $ tk 2 $ rep "grrp")
  32. $ [5, -11, -11, 4, 0, -78, -78, -99]
  33.  
  34. -- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  35. -- @ Georg, executed in ghci, what is `gutStr u` ??? @
  36. -- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  37. --
  38. -- HINT: u :: [Char]
  39. --
  40. -- Rules:
  41. --
  42. -- Functions from libraries: {abs, ord, chr}
  43. -- abs :: Num a => a -> a
  44. -- Example: abs (-5) = 5
  45. --
  46. -- ord :: Char -> Int
  47. -- Example: ord 'A' = 65
  48. --
  49. -- chr :: Int -> Char
  50. -- Example: chr 65 = 'A'
  51. --
Add Comment
Please, Sign In to add comment