... | @@ -142,7 +142,7 @@ The implementation of the view: |
... | @@ -142,7 +142,7 @@ The implementation of the view: |
|
view Empty = Nil
|
|
view Empty = Nil
|
|
view (Single a) = Cons a Empty
|
|
view (Single a) = Cons a Empty
|
|
view (Join (l | Cons xh xt <- view l) y) = Cons xh $ Join xt y
|
|
view (Join (l | Cons xh xt <- view l) y) = Cons xh $ Join xt y
|
|
view (Join (l | Nil <- view) l) = view y
|
|
view (Join (l | Nil <- view l) y) = view y
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
... | @@ -217,12 +217,12 @@ module Set(Set, empty, insert, delete, has) where |
... | @@ -217,12 +217,12 @@ module Set(Set, empty, insert, delete, has) where |
|
| otherwise = Nothing
|
|
| otherwise = Nothing
|
|
|
|
|
|
delete :: a -> Set a -> Set a
|
|
delete :: a -> Set a -> Set a
|
|
delete x (r | Just s <- has r) = s
|
|
delete x (r | Just s <- has x r) = s
|
|
delete x s = s
|
|
delete x s = s
|
|
|
|
|
|
insert :: a -> Set a -> Set a
|
|
insert :: a -> Set a -> Set a
|
|
insert x (s | Just _ <- has x s) = s
|
|
insert x (s | Just _ <- has x s) = s
|
|
insert x (S xs) = S (x:xs)
|
|
insert x (S xs) = S (x:xs)
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
... | | ... | |