Commit e77852d4 authored by Peter Achten's avatar Peter Achten

fixed the overly restrictive types of filter and partition in Data.Set into polymorphic types

parent 0cdb454e
Pipeline #42467 passed with stage
in 2 minutes and 10 seconds
...@@ -370,8 +370,7 @@ intersections :: ![Set a] -> Set a | < a ...@@ -370,8 +370,7 @@ intersections :: ![Set a] -> Set a | < a
* sort (toList (filter (pred p) xs)) * sort (toList (filter (pred p) xs))
* =.= sort (removeDup ('StdList'.filter (pred p) (toList xs))) * =.= sort (removeDup ('StdList'.filter (pred p) (toList xs)))
*/ */
filter :: !(a -> Bool) !(Set a) -> Set a | < a filter :: !(a -> Bool) !(Set a) -> Set a
special a=Int; a=String
/** /**
* Partition the set into two sets, one with all elements that satisfy the * Partition the set into two sets, one with all elements that satisfy the
...@@ -392,8 +391,7 @@ filter :: !(a -> Bool) !(Set a) -> Set a | < a ...@@ -392,8 +391,7 @@ filter :: !(a -> Bool) !(Set a) -> Set a | < a
* (true`,false`) = (toList true, toList false) * (true`,false`) = (toList true, toList false)
* xs` = true` ++ false` * xs` = true` ++ false`
*/ */
partition :: !(a -> Bool) !(Set a) -> (!Set a, !Set a) | < a partition :: !(a -> Bool) !(Set a) -> (!Set a, !Set a)
special a=Int; a=String
/** /**
* Split a set in elements less and elements greater than a certain pivot. * Split a set in elements less and elements greater than a certain pivot.
......
...@@ -198,13 +198,13 @@ hedgeInt blo bhi (Bin _ x l r) t2 ...@@ -198,13 +198,13 @@ hedgeInt blo bhi (Bin _ x l r) t2
* Filter and partition * Filter and partition
*--------------------------------------------------------------------*/ *--------------------------------------------------------------------*/
filter :: !(a -> Bool) !(Set a) -> Set a | < a filter :: !(a -> Bool) !(Set a) -> Set a
filter p (Bin _ x l r) filter p (Bin _ x l r)
| p x = link x (filter p l) (filter p r) | p x = link x (filter p l) (filter p r)
| otherwise = merge (filter p l) (filter p r) | otherwise = merge (filter p l) (filter p r)
filter _ tip = tip filter _ tip = tip
partition :: !(a -> Bool) !(Set a) -> (!Set a, !Set a) | < a partition :: !(a -> Bool) !(Set a) -> (!Set a, !Set a)
partition p (Bin _ x l r) partition p (Bin _ x l r)
#! (l1,l2) = partition p l #! (l1,l2) = partition p l
#! (r1,r2) = partition p r #! (r1,r2) = partition p r
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment