mirror of
https://github.com/correl/elm.git
synced 2024-12-19 19:14:14 +00:00
21 lines
405 B
Text
21 lines
405 B
Text
module Strain (..) where
|
|
|
|
import List
|
|
|
|
|
|
keep : (a -> Bool) -> List a -> List a
|
|
keep predicate list =
|
|
List.foldr (consIf predicate) [] list
|
|
|
|
|
|
discard : (a -> Bool) -> List a -> List a
|
|
discard predicate list =
|
|
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
|