Ricardo Wurmus <ricardo.wur...@mdc-berlin.de> skribis: > Ludovic Courtès <l...@gnu.org> writes:
[...] >> In theory it would be possible to do something like: >> >> (define (description->package repo meta) >> (stream-cons `(package …) >> (stream-unfold (lambda (state) >> (description->package >> repo >> (first-dependency state))) >> (lambda (state) >> (done? state)) >> (lambda (state) >> (next-dependency state)) >> (make-state propagate (setq))))) >> >> … where the state is roughly a pair containing the list of next >> dependencies and the set of already visited dependencies (to avoid >> duplicates). > > That’s a good hint. “stream-unfold” makes my head spin, to be honest. I had that feeling when I first met ‘unfold’, but my head has kept spinning since then so I’m fine. ;-) Here’s an example that should probably be added to the Guile manual: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,use(srfi srfi-1) scheme@(guile-user)> (unfold (lambda (x) (> x 10)) (lambda (x) (* 2 x)) 1+ 0) $2 = (0 2 4 6 8 10 12 14 16 18 20) --8<---------------cut here---------------end--------------->8--- Ludo’.