bsc-leon-vatthauer/slides/code-examples/example.hs
2024-01-22 17:57:12 +01:00

13 lines
254 B
Haskell

hd :: [a] -> a
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)