Skip to content

Instantly share code, notes, and snippets.

@waseem
Last active August 29, 2015 14:06
Show Gist options
  • Save waseem/d5ddff735f3e863b47a4 to your computer and use it in GitHub Desktop.
Save waseem/d5ddff735f3e863b47a4 to your computer and use it in GitHub Desktop.
authors = [
%{ name: "Jose", langauge: "Elixir" },
%{ name: "Matz", langauge: "Ruby" },
%{ name: "Larry", language: "Perl" }
]
language_with_an_r = fn (:get, collection, next_fn) ->
for row <- collection do
if String.contains?(row.language, "r") do
next_fn.(row)
end
end
end
get_in(authors, [langauge_with_an_r, :name]) # => ["Jose", nil, "Larry"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment