[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SRFI 121: Generators

This page is part of the web mail archives of SRFI 121 from before July 7th, 2015. The new archives for SRFI 121 contain all messages, not just those from before July 7th, 2015.

No, it can be anything with a for-each function with the right
signature.  A positive integer is a collection, given this function:

(define (integer-for-each proc n)
  (let loop ((n n))
    (unless (= n 0)
      (proc (remainder n 10))
      (loop (quotient n 10)))))

I'm not sure how best to explain this.  Suggestions, anyone?

OK, I now understand make-for-each-generator's intended behavior, which sounds fine to me, but I think the SRFI text could be better since I didn't understand it until you elaborated.

How about inserting something like the following after the first sentence:

"for-each must be a procedure that, when called as
(for-each proc obj)
calls proc on each element of obj. R7RS for-each, string-for-each, and vector-for-each procedures are examples of appropriate procedures. The values returned by proc are those that are generated by the returned generator."
You're right, it is unclear.  Given the existence of a generator
operation for deleting neighbor duplicates, we might as well assume
that there are none.

Sounds good. Yes, if there's a duplicate-filter procedure it's easy enough for a programmer to call it when needed.