SHARE
TWEET

Untitled

a guest Sep 15th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --
  2. sumCustom :: (Num a) => [a] -> a
  3. sumCustom [] = 0
  4. sumCustom (x:xs) = x + sumCustom xs
  5. --
  6. (<+>) :: [a] -> [a] -> [a]
  7. (<+>) [] xs = xs
  8. (<+>) (x:xs) ys = x : (xs <+> ys)
  9. --
  10. reverseCustom :: [a] -> [a]
  11. reverseCustom [] = []
  12. reverseCustom (x:xs) =  reverseCustom xs <+> [x]
  13. --
  14. initCustom :: [a] -> [a]
  15. initCustom [] = error "Empty list"
  16. initCustom (x:[]) = []
  17. initCustom (x:xs) = x: initCustom xs
  18. --
  19. lastCustom :: [a] -> a
  20. lastCustom [] = error "Empty list"
  21. lastCustom (a:[]) = a
  22. lastCustom (x:xs) = lastCustom xs
  23. --
  24. initsCustom :: [a] -> [[a]]
  25. initsCustom [] = error "Empty list"
  26. initsCustom (x:[]) = [[x]]
  27. initsCustom (x:xs) = initsCustom(initCustom(x:xs)) <+> [x:xs]
  28. --
  29. tailsCustom :: [a] -> [[a]]
  30. tailsCustom [] = error "Empty list"
  31. tailsCustom (x:[]) = [[x]]
  32. tailsCustom (x:xs) =   [x:xs] <+> tailsCustom(xs)
  33. --
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top