question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does transduce take its arguments in the wrong order?

See original GitHub issue

I realized something yesterday about transduce that has bothered me for a long time. Every time I use it I pretty much make a custom transducer function but the accumulator function and the initial argument pretty much only varies in two ways.

  • Case 1: I build up a list of elements where xf is flip(append) and acc is []
  • Case 2: I build up a sum where xf is add and acc is 0

Because of this, it seems a better argument order would be transduce(xf, acc, transducer, list). With this I could create

  • transduceToList = transduce(flip(append), [])
  • transduceToSum = transduce(add, 0)

I suspect that other uses of transduce would follow the same pattern.

I realize that transduce is not a ramda invention and that it probably follows a format from somewhere else. I just wanted to bring this up for discussion.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
CrossEyecommented, Jan 18, 2018

Yes, this is the expected behavior. There are several good articles, mostly Clojure related:

0reactions
franciscotlncommented, Jan 16, 2018

I’m having problem in understanding something kinda related to “order”. I’m using R.into with a composed transducer but the order of the functions calls inside R.compose is the opposite (left to right), like pipe, and vice-versa: using R.pipe the functions are called from right to left. https://goo.gl/ZuKUvN

Is this the expected behaviour?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transducers: sequence versus eduction - Google Groups
Transducers make different trade offs than sequences and there will always be cases where one or the other is a better choice. I...
Read more >
Understanding transducers - Andrey Listopadov
First, a bit of theory. A transducer is a function that describes the process of transformation, without knowing how exactly the thing it...
Read more >
Clojure transducers behavior - Stack Overflow
1 Answer 1 · Yes, xf == xform is a "transducer". · Your my-identity function does not compile. · Your argument to your...
Read more >
Transduce does more work than necessary · Issue #1792 · ramda ...
Hi @cristianocd ,. You're transducer is mapping before it is taking. See eg #1790. You can either change the order of your arguments...
Read more >
Grokking Clojure transducers - /dev/solita
In essence, a transducer is a function that takes a reducing function (like conj ) and turns it into a new, more awesome...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found