Reply To: beginner Lists question

Home Forums Basic Erlang beginner Lists question Reply To: beginner Lists question


Hello, this is very simple. Because A in this case not lists but integer.
If you call function such this:
you get result 1.
Or you also can add this equation to the function between 2 old:
list_length(P) when is_integer(P)->1;

Although since the number of not a list would be correct to add the following line to avoid other errors.
list_length(P) when not is_list(P)->{error,not_list}.

  • This reply was modified 1 year ago by  Shared_essence. Reason: add note