Skip to content

Instantly share code, notes, and snippets.

@dwickstrom
Created July 5, 2017 16:21
Show Gist options
  • Save dwickstrom/b9b12d637aab1555db6b11e8e114a169 to your computer and use it in GitHub Desktop.
Save dwickstrom/b9b12d637aab1555db6b11e8e114a169 to your computer and use it in GitHub Desktop.
destructure head/tail from list
// take :: Int -> [a] -> [a]
const take = n => ([x, ...xs]) =>
!x ?
[] :
n === 0 ?
[] :
[x, ...take (n-1) (xs)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment