Skip to content

Instantly share code, notes, and snippets.

@BFalkner
Created April 12, 2012 19:25
Show Gist options
  • Select an option

  • Save BFalkner/2370328 to your computer and use it in GitHub Desktop.

Select an option

Save BFalkner/2370328 to your computer and use it in GitHub Desktop.
> _.split([1, 2, 3, 4], function(item) { return [item, item*2]; })
[1, 2, 2, 4, 3, 6, 4, 8]
_.mixin({
split: function(collection, func) {
if (collection.length === 0) return [];
return func(_.first(collection)).concat(_.split(_.rest(collection), func));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment