Created
February 5, 2013 21:45
-
-
Save AitorATuin/4718038 to your computer and use it in GitHub Desktop.
takeN in coffeescript. Take n elements from array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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