Skip to content

Instantly share code, notes, and snippets.

@CyrusOfEden
Last active September 6, 2015 15:34
Show Gist options
  • Save CyrusOfEden/6c5772fd197e5b76fc04 to your computer and use it in GitHub Desktop.
Save CyrusOfEden/6c5772fd197e5b76fc04 to your computer and use it in GitHub Desktop.
def delete_all(collection, value) when is_list(collection) do
List.foldr collection, [], fn
x, acc when x == value ->
acc
x, acc ->
[x|acc]
end
end
@augiedb
Copy link

augiedb commented Sep 3, 2015

Thanks! I'll add that to the original post tonight!

@CyrusOfEden
Copy link
Author

Apparently you can't use ^value to match within the anonymous function's heads. I tested this and it works.

@augiedb
Copy link

augiedb commented Sep 6, 2015

Yup, that does it. Thanks! I'll update the original post with the this in the coming days!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment