kino/src/Misc.hs

8 lines
130 B
Haskell

module Misc where
infixl 3 !?
(!?) :: [a] -> Int -> Maybe a
[] !? i = Nothing
(x:xs) !? 0 = Just x
(x:xs) !? n = xs !? (n-1)