Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Completed
    • Affects versions: 1.9.908
    • Fix versions: None
    • Labels:
    • Approval:
      Accepted
    • Patch:
      Code and Test

      Description

      Have iterate, cycle, and repeat return custom types that are directly reducible.

      Background and inspiration are CLJ-1603 Closed and http://insideclojure.org/2015/01/18/reducible-generators/

      While (satisfies? IReduce (iterate inc 0)) returns true this is via LazySeq, as opposed to, for example (satisfies? IReduce (range)) which involves a custom type.

      One motivation would be the ability to transduce over large generated collections without consuming memory (which otherwise occurs due to lack of locals clearing).

      For example, the following uses very little memory:

      (transduce (comp (map inc) (filter odd?) (take 1e8)) + (range))
      

      where this semantically equivalent form consumes gigabytes:

      (transduce (comp (map inc) (filter odd?) (take 1e8)) + (iterate inc 0))
      

      It is expected that, to implement this ticket, three new types would be introduced, akin to the existing Range class, porting as much as possible from the existing types implemented in Clojure for iterate, cycle, and repeat.

        Attachments

          Activity

            People

            • Assignee:
              dnolen David Nolen
              Reporter:
              mfikes Mike Fikes
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: