Hi, the naming of your args [x r] is a bit confusing as x is usually the
second item and the first is often caled acc (and it's also the argument
passed to the completing arity (1-arg)).

However acc is a name inherited from reduce and does not really represent
its actual purpose. *You have to consider acc as an opaque linear value
storing the state of the transducing context.*

Here are my rules to write a transducer:
0-arg: always call (rf) -- nothing much to do as depending on how the
transducer is used it may not even be called (eg transduce with init value)
1-arg: it's an opportunity to flush state of the current transducer, so
several calls to the downstream rf with 2 args is possible. However one
should always end by calling the 1-arg arity of rf. There's no guarantee it
will be called (eg sequence or chan)
2-arg: don't forget to think about how to handle reduced values (unwrap,
rewrap or porpagate)

Hope this helps.

Christophe

On Tue, Sep 5, 2017 at 11:00 AM, Peter Hull <peterhul...@gmail.com> wrote:

> On Tuesday, 5 September 2017 00:07:07 UTC+1, Alex Miller wrote:
>>
>> When you say "the" answer here, that doesn't make sense to me.
>>
> Nor me. But, I think I've got it now, thanks for your help. The question I
> should have asked was "what is the purpose of the ([x] ...) arity in an
> eduction?"  I wish I could phrase my questions as clearly as you phrase
> your answers!
>
>
>> The termination value in an eduction is just a nil, so x is nil in the
>> ([x] ...) arity.
>>
>
>  I couldn't understand why, in eduction, the function was being called
> with arity 1 at all if the result was not being used. Is this so that
> stateful transducers can 'clean up' their state in some way at the end?
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
On Clojure http://clj-me.cgrand.net/
Clojure Programming http://clojurebook.com
Training, Consulting & Contracting http://lambdanext.eu/

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to