3 ms·
No. In Erlang, is_list([]) is true. The correct implementation for checking if a list is empty would have been a pattern match, something akin to case List of
by lostcolony 12y ago
No. In Erlang, is_list([]) is true.
The correct implementation for checking if a list is empty would have been a pattern match, something akin to
case List of
[] -> empty;
[_ | _] -> not_empty
end.
Or, you know. Reading the API docs and using queue:is_empty(Queue), which is O(1) instead of O(n) (which queue:len(Queue) is -explicitly stated to be-).