Skip to content

Instantly share code, notes, and snippets.

@shoebsd31
Forked from samgiles/flatMap.js
Created December 21, 2017 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoebsd31/9a819744b3fa442fc31f87cf68adcc53 to your computer and use it in GitHub Desktop.
Save shoebsd31/9a819744b3fa442fc31f87cf68adcc53 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