Skip to content

Instantly share code, notes, and snippets.

@epitron
Created October 19, 2015 21:42
Show Gist options
  • Save epitron/cbbcdcddb955d00151ad to your computer and use it in GitHub Desktop.
Save epitron/cbbcdcddb955d00151ad to your computer and use it in GitHub Desktop.
defmodule C do
def map([], _f), do: []
def map([ head | tail ], f), do: [ f.(head) | map(tail, f) ]
end
# works
IO.inspect C.map [1,2,3,4,5], fn x -> x*x end
# doesn't work
IO.inspect C.map [1,2,3,4,5], &1*&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment