Skip to content

Instantly share code, notes, and snippets.

@iamed2
Created August 18, 2014 18:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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