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

14 lines
254 B
Haskell
Raw Normal View History

2024-01-03 19:51:04 +01:00
hd :: [a] -> a
hd (x : _) = x
main :: IO ()
2024-01-11 13:38:32 +01:00
main = do
print (Main.reverse ([1,2,3]::[Int]))
print (hd []::[String])
2024-01-06 15:04:04 +01:00
reverse :: [a] -> [a]
2024-01-11 13:42:27 +01:00
reverse l = reverseAcc l []
2024-01-06 15:04:04 +01:00
where
2024-01-11 13:42:27 +01:00
reverseAcc [] a = a
reverseAcc (x:xs) a = reverseAcc xs (x:a)