On 07.07.24 13:30, Zelphir Kaltstahl wrote:
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.

OK thanks again for the idea with the continuation. I now have a solution in the repository and set-find is implemented. Neat!

--
repositories: https://notabug.org/ZelphirKaltstahl


Reply via email to