bsc-leon-vatthauer/slides/code-examples/example.hs
2024-01-11 13:38:32 +01:00

13 lines
237 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 = reverseAcc []
where
reverseAcc = foldl (flip (:))