Re: fxmapping-unfold(-maybe)
Wolfgang Corcoran-Mathe 14 Jun 2021 16:09 UTC
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.
> > This must be valid if we state that invoking `delete' returns the
> > updated fxmapping. However, I believe that this constrains
> > fxmapping-update to calling the updater procedure in tail-context,
> > which may be inconvenient for some implementations (i.e. those
> > using structures which are naturally constructed via recursion).
> >
>
> We have discussed a similar thing some time ago, haven't we?
>
> 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.
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.
--
Wolfgang Corcoran-Mathe <xxxxxx@sigwinch.xyz>
"In a bureaucracy, the file cards are reality. Punching
new holes recreates the world." --Alan Moore, _V For Vendetta_