Composing transducers; Order of composition and order of execution

34 views Asked by At

There is a paragraph here stating:

Composition of the transformer runs right-to-left but builds a transformation stack that runs left-to-right (filtering happens before mapping in this example).

I don't get it. What does this mean: Composition of the transformer runs right-to-left (from the bottom in this example)

(def xf
  (comp
    (filter odd?)
    (map inc)
    (take 5)))

For me all I see is how this composition will execute, it will filter, map and take. What's the point of composition order from the bottom. It seems an important point in the article so I try to not miss the point.

1

There are 1 answers

0
Curcuma_ On BEST ANSWER

I will try to answer quickly; Begging the question:

Compiler knows map is followed by a take. So unfolding the composition to compile it, it will sequentially define map, then take function, although execution graph starts from the bottom.