2016-03-17 01:38:35 +00:00
|
|
|
module Strain (..) where
|
2015-10-13 18:56:46 +00:00
|
|
|
|
|
|
|
import List
|
|
|
|
|
2016-03-17 01:38:51 +00:00
|
|
|
|
|
|
|
keep : (a -> Bool) -> List a -> List a
|
|
|
|
keep predicate list =
|
2016-03-17 01:52:25 +00:00
|
|
|
List.foldr (consIf predicate) [] list
|
2016-03-17 01:38:51 +00:00
|
|
|
|
2015-10-13 18:56:46 +00:00
|
|
|
|
|
|
|
discard : (a -> Bool) -> List a -> List a
|
2016-03-17 01:38:51 +00:00
|
|
|
discard predicate list =
|
2016-03-17 01:52:25 +00:00
|
|
|
List.foldr (consIf (\v -> not <| predicate v)) [] list
|
|
|
|
|
|
|
|
|
|
|
|
consIf : (a -> Bool) -> a -> List a -> List a
|
|
|
|
consIf predicate value list =
|
|
|
|
if predicate value then
|
|
|
|
value :: list
|
|
|
|
else
|
|
|
|
list
|