accumulate-continuation? added by anonymous on Thu Nov 9 17:03:31 2017

; an iterating search that accumulates its results by recursion (?)
(define (accumulate-continuation f #!optional (iter-state '(0 . 0)) (accumulator '())) ; f: state -> (state result) is the searcher function ; in this case this turns out to be pointles because the next state can be derived from the result (inc both coords)
  (match-let ([(next-state . result) (f iter-state)]) ;get next state and the result of calling f with the current state
    (if (not (null? result))
        (ar-find f next-state (cons result accumulator)) ;recurse with next state and the result saved in the accumulator
        accumulator) )) ;if no result returned: finished -> return results