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

13 lines
208 B
Haskell
Raw Normal View History

2024-01-03 19:51:04 +01:00
hd :: [a] -> a
hd [] = error "empty list"
hd (x : _) = x
main :: IO ()
main = print (hd []::[String])
2024-01-06 15:04:04 +01:00
reverse :: [a] -> [a]
reverse l = rev l []
where
rev [] a = a
rev (x:xs) a = rev xs (x:a)