12345678910111213141516 |
- (define-module (utils collections))
- (define-public make-reducer
- (lambda (col-next-unvisited col-rest-unvisited col-exhausted?)
- "Return a procedure, which goes through the collection. Currently this
- implementation has some assumptions, which are rather biased towards linked list
- like data structures."
- (lambda (col reduction-proc init)
- (let loop ([acc init] [remaining col])
- (cond
- [(col-exhausted? remaining) acc]
- [else
- (loop (reduction-proc acc (col-next-unvisited remaining))
- (col-rest-unvisited remaining))])))))
|