Skip to content

Instantly share code, notes, and snippets.

@egor-smirnov
Forked from samgiles/flatMap.js
Created September 15, 2016 16:15
Show Gist options
  • Select an option

  • Save egor-smirnov/f0a764ff305a97f606048d2f9c98c413 to your computer and use it in GitHub Desktop.

Select an option

Save egor-smirnov/f0a764ff305a97f606048d2f9c98c413 to your computer and use it in GitHub Desktop.
Javascript flatMap implementation
// [B](f: (A) ⇒ [B]): [B] ; Although the types in the arrays aren't strict (:
Array.prototype.flatMap = function(lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment