Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --
- sumCustom :: (Num a) => [a] -> a
- sumCustom [] = 0
- sumCustom (x:xs) = x + sumCustom xs
- --
- (<+>) :: [a] -> [a] -> [a]
- (<+>) [] xs = xs
- (<+>) (x:xs) ys = x : (xs <+> ys)
- --
- reverseCustom :: [a] -> [a]
- reverseCustom [] = []
- reverseCustom (x:xs) = reverseCustom xs <+> [x]
- --
- initCustom :: [a] -> [a]
- initCustom [] = error "Empty list"
- initCustom (x:[]) = []
- initCustom (x:xs) = x: initCustom xs
- --
- lastCustom :: [a] -> a
- lastCustom [] = error "Empty list"
- lastCustom (a:[]) = a
- lastCustom (x:xs) = lastCustom xs
- --
- initsCustom :: [a] -> [[a]]
- initsCustom [] = error "Empty list"
- initsCustom (x:[]) = [[x]]
- initsCustom (x:xs) = initsCustom(initCustom(x:xs)) <+> [x:xs]
- --
- tailsCustom :: [a] -> [[a]]
- tailsCustom [] = error "Empty list"
- tailsCustom (x:[]) = [[x]]
- tailsCustom (x:xs) = [x:xs] <+> tailsCustom(xs)
- --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement