Skip to content

Instantly share code, notes, and snippets.

@AitorATuin
Created February 5, 2013 21:45
Show Gist options
  • Select an option

  • Save AitorATuin/4718038 to your computer and use it in GitHub Desktop.

Select an option

Save AitorATuin/4718038 to your computer and use it in GitHub Desktop.
takeN in coffeescript. Take n elements from array
n = [1..3]
takeN = (n) -> (arr) ->
_add = (arr1,arr2) -> (i) -> arr1[i] = arr2[i]
arr1 = []
(_add arr1, arr) i for i in [0..n-1]
test = ["a","b","c","d","e"]
res = (takeN 2) test
alert(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment