wiki:Functions/Nth

nth

(!!) :: [a] -> Int -> a
(x:xs) !! 0  =  x
(x:xs) !! n  =  xs !! n-1
nth(1, [H|_])            -> H;
nth(N, [_|T]) when N > 1 -> nth(N - 1, T).
Last modified 22 months ago Last modified on May 18, 2018, 8:33:32 AM
Note: See TracWiki for help on using the wiki.