Skip to content

Instantly share code, notes, and snippets.

@lubien
Last active August 4, 2019 03:23
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lubien/c13ac575efb408917b8a7bd66e0f35ce to your computer and use it in GitHub Desktop.
Save lubien/c13ac575efb408917b8a7bd66e0f35ce to your computer and use it in GitHub Desktop.
Dado o array de dictionary abaixo some o total dos valores (https://gist.github.com/anabastos/fbdfef7fcc64105e76e5e26218ebf7e6)
const
composeN = (...fs) => x =>
fs.reduceRight((x, f) => f(x), x)
, map = f => xs =>
xs.map(f)
, reduce = f => xs =>
xs.reduce(f)
, sum = (x, y) => x + y
, dictionary =
[ { '5': 50, '6': 60 }
, { 'A': 10 }
, { 'YEEZY': 30 }
]
composeN(
reduce(sum),
map(reduce(sum)),
map(Object.values)
)(dictionary)
@halan
Copy link

halan commented Mar 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment