Erlang's equivalent of Haskell's as-patterns

473 Views Asked by At

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

name@(x:xs)

1

There are 1 best solutions below

3
On BEST ANSWER

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]).