Sunday, 25 April 2010

SplitAt (Alternate definition)



let rec splitAt n xs = match (n, xs) with
                       | 0, xs -> ([], xs)
                       | _, [] -> ([], [])
                       | n, x::xs -> let (xs', xs'') = splitAt (n - 1) xs in
                                     (x::xs', xs'')

No comments: