elemen pertama dalam daftar haskell
list = [1, 2, 3]
head :: [a] -> a
head (x:_) = x
head list -- 1
Hippo_error
list = [1, 2, 3]
head :: [a] -> a
head (x:_) = x
head list -- 1
1 : [2, 3]
--return [1, 2, 3]
--Haskell Lists' are 0 based
--Let xs be a list from where we want the n-th element
?> xs !! n
--Example
?> [1, 2, 3] !! 1
?> 2