|
|
|
|
|
by digitalzombie
3434 days ago
|
|
Elixir is prettier than Erlang but it really mess up on certain things. Erlang have pattern matching via function with same name and you can tell if it's a group of pattern matching with semicolon and period. But with Elixir you can't tell it's just def and end. Erlang's: -module(recursive). -export([fac/1]). fac(N) when N == 0 -> 1; fac(N) when N > 0 -> N * fac(N-1). You can tell fac(N) both are in a group of pattern matching cause ';' and '.'. The '.' denote the last pattern matching function. Elixir: defmodule Factorial do def of(0), do: 1
def of(n), do: n * of(n-1)
endYou can't tell because there is no ';' and '.'. This is a trivial case but when your Elixir's module have a tons of function in it, this issue become relevant. |
|