|
From: | Zelphir Kaltstahl |
Subject: | Re: Find an element in a functional set (guile-pfds) |
Date: | Sun, 7 Jul 2024 11:30:47 +0000 |
On 07.07.24 13:01, Maxime Devos wrote:
>Maybe bbtree-fold can be used, but that would not "early exit" as soon as it has found an item, that satisfies some specified predicate. You can use escape continuations to do an early exit: ;; On success, return stuff-to-return. Otherwise, return the symbol ‘no-match’. (let/ec escape(bbtree-fold [...] [... when a match is found, use (escape stuff-to-return)] [...])'no-match) Best regards, Maxime Devos.
Ah what wonderful idea! I did not think of it! Thank you!There is one more issue though: The underlying tree implementation cannot be accessed from the functions exported by the set module. I guess I could get at that using some @@ magical thing?
In the end it would still feel a bit like a hack to hack around the limited exports of the module, but I guess I would have exported that function anyway, had I to write this implementation, so I figure that would be OK.
-- repositories:https://notabug.org/ZelphirKaltstahl
[Prev in Thread] | Current Thread | [Next in Thread] |