Introduce a directly reducible tree-seq implementation.
In a sense, tree-seq is akin to iterate in that both are sequence generator functions which accept higher order functions that are used to generate the sequence: While iterate takes a single function that operates on the previous value to produce the subsequent value, tree-seq takes two functions, and has some interesting recursive nature that makes it differ from iterate. Additionally, tree-seq can produce infinite as well as finite sequences, while iterate can only produce infinite sequences. Regardless, tree-seq is amenable to similar optimizations that were done in CLJS-2445 for iterate.
This high-level sketch shows how a directly-reducible tree-seq can be built upon the existing directly-reducible iterate. While this code has great perf characteristics, it lacks IPending support, but that can be addressed via a production patch that adds a new TreeSeq deftype.
Introduce a directly reducible
tree-seq
implementation.In a sense,
tree-seq
is akin toiterate
in that both are sequence generator functions which accept higher order functions that are used to generate the sequence: Whileiterate
takes a single function that operates on the previous value to produce the subsequent value,tree-seq
takes two functions, and has some interesting recursive nature that makes it differ fromiterate
. Additionally,tree-seq
can produce infinite as well as finite sequences, whileiterate
can only produce infinite sequences. Regardless,tree-seq
is amenable to similar optimizations that were done in CLJS-2445 foriterate
.This high-level sketch shows how a directly-reducible
tree-seq
can be built upon the existing directly-reducibleiterate
. While this code has great perf characteristics, it lacksIPending
support, but that can be addressed via a production patch that adds a newTreeSeq
deftype.