Intuitively, I think both of them should return an empty list. Could you fix me? Why not?
Good - head- [a] -> a. It returns a single, first element; no list.
And when the first list is not in the empty list? Well, what to return? You cannot create a type value afrom nothing, so all that remains undefinedis an error.
And tail? A tail is basically a list without its first element - i.e. One element is shorter than the original. You cannot defend these laws when there is no first element.
, ( , tail [] == []). undefined.
:
, , , ? , - , optionnal, ?
, , , . , , . : * / ** - .
sum [] = 0
sum (x:xs) = x + sum xs
, , , .