1.0.0 • Published 4 years ago

@m1yh3m/foldr.fn.node.lib v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

foldr

Inspired by https://wiki.haskell.org/Foldr_Foldl_Foldl'

usage

const foldr = require('@m1yh3m/foldr.fn.node.lib')

const sum = (a, b) => a + b         // for numbers
const concatenate = (a, b) => a + b // for strings

foldr(sum, 0, [1, 2, 3, 4, 5, 6]) // should be 21
foldr(concatenate, '', ['a ', 'string ', 'is ', 'concatenated.']) // should be 'a string is concatenated.'
1.0.0

4 years ago