Created
November 19, 2017 23:55
-
-
Save mattvanhorn/26c7a0d1e6d18faf912d3e160638e233 to your computer and use it in GitHub Desktop.
Trying to make ruby-like elm helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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