Skip to content

Instantly share code, notes, and snippets.

@loosechainsaw
Created May 7, 2014 13:31
Show Gist options
  • Save loosechainsaw/4ea81b50f78f944377ab to your computer and use it in GitHub Desktop.
Save loosechainsaw/4ea81b50f78f944377ab to your computer and use it in GitHub Desktop.
Haskell Implementation of Split At
seperateAt :: Int -> [a] -> ([a],[a])
seperateAt 0 [] = ([], [])
seperateAt 0 xs = ([], xs)
seperateAt n (x: []) = (x : [], [])
seperateAt n (x:xs) =
let result = (seperateAt (n - 1) xs)
in (x : fst result, snd result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment