Skip to content

Instantly share code, notes, and snippets.

@dimitris-papadimitriou-chr
Created July 1, 2020 20:37
Show Gist options
  • Select an option

  • Save dimitris-papadimitriou-chr/2610f3cb5d3b176c33da1208d8345313 to your computer and use it in GitHub Desktop.

Select an option

Save dimitris-papadimitriou-chr/2610f3cb5d3b176c33da1208d8345313 to your computer and use it in GitHub Desktop.
var sum = fold([2, 3, 4], Sum.empty, Sum.concat);
var product = fold([2, 3, 4], 1, (x, y) => x * y);
var max = fold([2, 3, 4], Number.MIN_SAFE_INTEGER, (x, y) => x > y ? x : y);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment