Created
August 18, 2014 18:42
-
-
Save iamed2/817c91050bd3126eaac7 to your computer and use it in GitHub Desktop.
Partition a collection into two collections using a predicate
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
function partition(f::Function, collection) | |
u = similar(collection) | |
v = similar(collection) | |
for el in collection | |
if f(el) | |
push!(u, el) | |
else | |
push!(v, el) | |
end | |
end | |
return u, v | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment