bsc-leon-vatthauer/slides/code-examples/example.hs

14 lines
281 B
Haskell

hd :: [a] -> a
hd [] = error "empty list"
hd (x : _) = x
main :: IO ()
main = do
print (Main.reverse ([1,2,3]::[Int]))
print (hd []::[String])
reverse :: [a] -> [a]
reverse l = reverseAcc l []
where
reverseAcc [] a = a
reverseAcc (x:xs) a = reverseAcc xs (x:a)