Skip to content

Instantly share code, notes, and snippets.

@YannickLeRoux
Created February 15, 2021 23:26
Show Gist options
  • Save YannickLeRoux/7c2c8421133d79a5816923adad83e03f to your computer and use it in GitHub Desktop.
Save YannickLeRoux/7c2c8421133d79a5816923adad83e03f to your computer and use it in GitHub Desktop.
Example Ramda - compose map and reduce
import * as R from 'ramda'
const foods = [{item: 'bread', calories: 500},{item: 'cheese', calories: 300},{item: 'ham', calories: 200}]
const getTotalCalories = R.compose(R.reduce(R.add,0),R.map(R.prop('calories')))
console.log(getTotalCalories(foods))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment