Skip to main content

Search

Items tagged with: function



I had no idea functions could be passed around as variables in Elixir :blobcatsweats:
iex(1)> f = fn x -> x*x end
<a class="hashtag" data-tag="function" href="https://gleasonator.com/tag/function">#Function</a>&lt;44.79398840/1 in :erl_eval.expr/5&gt;
iex(2)&gt; is_function(f)
true
iex(3)&gt; f.(4)
16

I know this is a basic feature of most languages, but I’ve been working around it this whole time because I thought it wasn’t possible.