Two short answers: (1)
(): ()
, (2)
Bool: True, False
Write a function that takes a three-element list and returns a 2-tuple
with the last then first element of the list.
f [x,_,z] = (z,x)
What is the type of the function f
from the previous question?
f :: [b] -> (b, b)
What is the head and the tail of the list [3,4,5]
?
3
and [4,5]
What is a very fast operation with a "cons" list? What's a slow one?
Fast: "Add" an element at its beginning. Slow: Get its length.
What's the basic idea of patterns in Haskell?
Bind names to elements of a data structure.
EC ½ point: What's a case where we must use a guard instead of a pattern?
A pattern can't match a range of values.