Skip to content

Instantly share code, notes, and snippets.

@iamed2
Created August 18, 2014 18:42
Show Gist options
  • Save iamed2/817c91050bd3126eaac7 to your computer and use it in GitHub Desktop.
Save iamed2/817c91050bd3126eaac7 to your computer and use it in GitHub Desktop.
Partition a collection into two collections using a predicate
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