[erlang-questions] newbie: how to ignore the rest in a variable length tuple?

Lev Walkin vlm@REDACTED
Sat Mar 1 01:53:35 CET 2008


Paul Fisher wrote:
> c1( {x, B, C, D} ) -> ok;
> c1( Y ) when is_tuple(Y), element(1, Y) =:= y -> ok.
> 
> if you want to restrict Y to 4 or 5 elements only, then add:
> 
>  length(Y) >= 4, length(Y) =< 5
> 
> to the list of guards.


tuple_size, perhaps

-- 
vlm



More information about the erlang-questions mailing list