[ prog / sol / mona ]

prog


What are you working on?

70 2019-02-18 00:58

http://ix.io/1Bix

- Leaf-cumulate-iter continues to suffer from the last point of >>51.
- Leaf-cumulate is an instance of gen-leaf-fold with a pair holding the 'proc' output and the new-leaf as accumulator, as seen on the alternate branch. There's no need to repeat the iteration code.
- Radix-cumulate-iter and its containing 'if' are ripe for replacement by level-1-fold.

71 2019-02-18 01:00

http://ix.io/1Bix

Radix-fold-right can be unified with the normal fold by writing a function that folds an extracting map over a range iteration. A range would have start, step and end values, and would support negative steps. The extractor would receive the source object and the current index. The folding procedure would receive the accumulator, the current index and the extractor output. These steps would be combined to avoid the need to store an intermediate map, since map is eager in Scheme. This would make the normal and reversed folds differ only in the upward and downward ranges. It will also allow the unification of gen-leaf-fold and level-1-fold, since both are instances of a range-extract-fold with different ranges and extractors. You would also get some new things for free, like a radix-reversed-for-each.

72 2019-02-18 01:03

http://ix.io/1Bix

Radix-filter has two interleaved responsibilities. It produces a stream of items by filtering, and it consumes the stream with a radix builder. If you separate production and consumption, and interleave them in a function that links up a producer and a consumer, the radix building consumer becomes a fold. This can be written once and used to unify radix-filter, vector->radix and list->radix by using different producers. If you choose this path, copy-append! will also belong here by using an appending radix builder, which you already have. Then >>16 can be addressed by a generic buffering producer that wraps the real producer. The producer+consumer design can then be unified with range-extract-fold by making the fold a consumer and range-extract a producer.

199


VIP:

do not edit these