Skip to content

Instantly share code, notes, and snippets.

@mattvanhorn
Created November 19, 2017 23:55
Show Gist options
  • Save mattvanhorn/26c7a0d1e6d18faf912d3e160638e233 to your computer and use it in GitHub Desktop.
Save mattvanhorn/26c7a0d1e6d18faf912d3e160638e233 to your computer and use it in GitHub Desktop.
Trying to make ruby-like elm helpers
listCount : (a -> Bool) -> List a -> Int
listCount test list =
list
|> List.filter test
|> List.length
listAll : (a -> Bool) -> List a -> Bool
listAll test list =
let
passed =
list
|> listCount test
in
passed == List.length list
listAny : (a -> Bool) -> List a -> Bool
listAny test list =
let
numElements =
listCount test list
in
numElements > 0
listNone : (a -> Bool) -> List a -> Bool
listNone test list =
not (listAny test list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment