Skip to content

Instantly share code, notes, and snippets.

@andrefbsantos
Forked from samgiles/flatMap.js
Created January 31, 2018 14:27
Show Gist options
  • Save andrefbsantos/7b303f392e3a0cb025853853b1146453 to your computer and use it in GitHub Desktop.
Save andrefbsantos/7b303f392e3a0cb025853853b1146453 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