-
-
Save sshine/1c909e27149dfd6081e99ef39cb3a7e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- A ConcatList is just a fancy way to divide lists using 'Concat' instead of | |
-- 'Cons'. Where 'Cons' took one element on the left, and a list on the right, | |
-- 'Concat' takes a list on both sides. | |
data ConcatList a | |
= Nil | |
| Single a | |
| Concat (ConcatList a) (ConcatList a) | |
deriving (Show) | |
-- The length of a list is the length of its sub-lists | |
myLength :: ConcatList a -> Int | |
myLength Nil = undefined | |
myLength (Single x) = undefined | |
myLength (Concat xs ys) = undefined | |
-- The sum of a list is the sum of all of its elements | |
mySum :: Num a => ConcatList a -> a | |
mySum Nil = undefined | |
mySum (Single x) = undefined | |
mySum (Concat xs ys) = undefined | |
-- The depth of a list is the most possible steps to reach a 'Nil'. | |
myDepth :: ConcatList a -> Int | |
myDepth Nil = undefined | |
myDepth (Single x) = undefined | |
myDepth (Concat xs ys) = undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment