from my talk at pdx-erlang in April 2014. Introducing Elixir from the perspective of someone who works primarily in a scripting language such as Ruby, Javascript or Python.
functions and avoids state and mutable data. Functional programming emphasizes functions that produce results that depend only on blah blah expressions blah blah blah declarative blah blah blah no side effects blah blah blah lambda calculus blah blah blah monads blah blah blah category theory source: wikipedia
\ -e "Chain.run(400_000)" {5325361, "Result is 400000"} that’s 400k processes spawning sequentially, running simultaneously in 5.3 seconds on a MacBook Air
= Keyword.get(body, :else, nil) quote do case unquote(condition) do false -> unquote(no) _ -> unquote(yes) quote writes to the output tree unquote writes variable content
= Keyword.get(body, :else, nil) quote do case unquote(condition) do val when val in [false, nil, 0, "", [], {}] -> unquote(no) _ -> unquote(yes) like javascript’s falsiness? here you go
number of items in bag def member?(collection, value) # {:ok, boolean} def reduce(collection, acc, fun) # apply fun to the collection enables Enum to use Bag values
result def handle_call(request, from, state) :: result def handle_cast(request, state) :: result def handle_info(info, state) :: result def terminate(reason, state) def code_change(oldVsn, state, extra) :: status OTP server interface definition
test math is correct (MathTest) ** (ExUnit.ExpectationError) expected: 5 to match pattern (=): 2 + 2 at test/math_test.exs:5 assertion types are implied by pattern matching & syntax tree