Created
August 30, 2014 23:01
-
-
Save k06a/39f527164e810ec63d26 to your computer and use it in GitHub Desktop.
Swift implementation of Haskell elem function
This file contains 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
func elem<T: Equatable>(item: @autoclosure ()->T) -> (@autoclosure ()->[T]) -> Bool { | |
return { (arr: @autoclosure ()->[T]) in find(arr(), item()) != nil } | |
} | |
let found = elem (2) ([1,2,3]) // Hope to avoid braces in future |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment