Am Mo., 14. Juni 2021 um 18:10 Uhr schrieb Wolfgang Corcoran-Mathe <xxxxxx@sigwinch.xyz>:
On 2021-06-14 17:41 +0200, Marc Nieper-Wißkirchen wrote:
> Am Mo., 14. Juni 2021 um 16:53 Uhr schrieb Wolfgang Corcoran-Mathe <
> xxxxxx@sigwinch.xyz>:
>
> > As a side note on naming, I think `fxmapping-accumulate' is a
> > good name; the only concern I have about it is that the very well-known
> > SICP used it to describe a fold procedure.
> >
>
> fxmapping-consume

As a name for the unfold?  This sounds like a fold, to me.

The procedure is consuming a stream of values as in pull-semantics.

But it is probably a bad name if it reminds you of a fold.

What about fxmapping-construct?

(Fold operations would then be fxmapping-destruct.)
 
> Example:
>
> (define alist-update
>   (lambda (ls key updater)
>     (call-with-prompt (default-prompt-tag)
>       (lambda ()
>         (let f ([ls ls])
>           (cond
>             [(null? ls) '()]
>             [(eqv? (caar ls) key)
>              (abort-to-prompt default-prompt-tag ls)]
>             [else (cons (car ls) (f (cdr ls)))])))
>       (lambda (k)
>         (updater (caar ls) (cdar ls)
>           (lambda (val)
>             (k (cons (cons key val) (cdr ls))))
>           (lambda ()
>             (k (cdr ls))))))))

Yes, sorry, we are back to this, again.

No problem. Eventually, we'll find a solution. And, along the way, we will have learned a lot.
 
That is a very nice example, though notably more complicated than the
basic recursive version.  It's also unfortunate that we don't have
portable access to delimited continuation operators.

Is it much more complicated than the basic recursive version? The code looks a bit blown up because I have used the bare, unsugared control operators. One can probably come up with some syntax (or a single procedure that packages everything) that allows recursion where a procedure called deep inside is called in tail-context with respect to the outer call.

If delimited control operators aren't available, one can still try an emulation with call/cc. Besides, there doesn't seem to be a good excuse for a Scheme not shipping with delimited continuations (or primitives on which they can be built).