Skip to content
#

transducers

Here are 57 public repositories matching this topic...

rubico
richytong
richytong commented Oct 1, 2020

Syntax

var T any,
  args ...any,
  accumulator any,
  reducer (any, T)=>any,
  init (...args=>accumulator)|accumulator

reduce.sync(reduce, init?)(...args) -> any

Synchronous reduce without promise handling. Only for arrays (for now)

const add = (a, b) => a + b

console.log(
  reduce.sync(add, 0)([1, 2, 3, 4, 5]),
) // 15
  1. Implement
filipdanic
filipdanic commented Oct 18, 2018
  • head – returns the first element
  • last – the opposite of head; returns the last element
  • tail - all elements except the first one
  • reduceRight – similar to how we implemented reduce
  • concat – takes in n-arrays and combines them. So concat(arr1, arr2, ...arrN)
  • take – returns the first n elements of an array. So take(n)(arr)
  • takeWhile – `takeWhile(condition)(a

Improve this page

Add a description, image, and links to the transducers topic page so that developers can more easily learn about it.

Curate this topic

Add this topic to your repo

To associate your repository with the transducers topic, visit your repo's landing page and select "manage topics."

Learn more

You can’t perform that action at this time.