simpler append function
This commit is contained in:
parent
604206776f
commit
ca0fea108f
@ -55,9 +55,7 @@ snoc (Multiple a b c) = Multiple a (b `snoc` c)
|
||||
append :: GoodList a -> GoodList a -> GoodList a
|
||||
append Empty ys = ys
|
||||
append (Singleton x) ys = cons x ys
|
||||
append xs Empty = xs
|
||||
append (Multiple a b c) (Singleton y) = Multiple a (snoc b c) y
|
||||
append (Multiple a b c) (Multiple d e f) = Multiple a (snoc b c `append` cons d e) f
|
||||
append (Multiple a b c) ys = cons a . append b $ cons c ys
|
||||
|
||||
join :: GoodList (GoodList a) -> GoodList a
|
||||
join Empty = Empty
|
||||
|
@ -3,6 +3,10 @@ import GoodList
|
||||
|
||||
abc :: GoodList Char
|
||||
abc = cons 'a' $ cons 'b' $ cons 'c' Empty
|
||||
def :: GoodList Char
|
||||
def = cons 'd' $ cons 'e' $ cons 'f' Empty
|
||||
|
||||
main :: IO ()
|
||||
main = print abc
|
||||
main = print abc >>
|
||||
print def >>
|
||||
print (abc `append` def)
|
||||
|
Loading…
Reference in New Issue
Block a user