Skip to content

Instantly share code, notes, and snippets.

@iamed2
Created Aug 18, 2014
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