Whats the difference between:
(v@(x:xs)) and (v:(x:xs)
Example function:
list [] = []
list (v@(x:xs)) = v : list xs
If i replace the (v@(x:xs)) with (v:(x:xs)) the function doesnt work.
Whats the difference between:
(v@(x:xs)) and (v:(x:xs)
Example function:
list [] = []
list (v@(x:xs)) = v : list xs
If i replace the (v@(x:xs)) with (v:(x:xs)) the function doesnt work.
v@(x:xs)
matches a list with one or more, with x
bound to the head, xs
to the tail, and v
to the entire list.
v:(x:xs)
matches a list with two or more elements, with v
bound to the first, x
to the second, and xs
to the rest.