diff options
-rw-r--r-- | p7.hs | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -0,0 +1,5 @@ +data NestedList a = Elem a | List [NestedList a] + +myFlatten :: NestedList a -> [a] +myFlatten (Elem x) = [x] +myFlatten (List x) = concatMap myFlatten x |
index : h99.git | ||
Haskell 99 problems |
summaryrefslogtreecommitdiff |
-rw-r--r-- | p7.hs | 5 |
@@ -0,0 +1,5 @@ +data NestedList a = Elem a | List [NestedList a] + +myFlatten :: NestedList a -> [a] +myFlatten (Elem x) = [x] +myFlatten (List x) = concatMap myFlatten x |