listhaskellerlangas-pattern

Erlang's equivalent of Haskell's as-patterns


How can I write in Erlang an equivalent of this Haskell snippet?

name@(x:xs)


Solution

  • You can do it with syntax like Name=[X|Xs]. An example usage is

    headlist([H|T]=L) -> io:format("List (~p) with head ~p ~n",[L,H]).