[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: handling duplicate elements

This page is part of the web mail archives of SRFI 113 from before July 7th, 2015. The new archives for SRFI 113 contain all messages, not just those from before July 7th, 2015.

Kevin Wortman scripsit:

> I guess that's sufficient for my association set application; I can change
> a mapping by removing any pre-existing association then adjoining a new
> one. It's not ideal, though, since that is two data structure operations
> instead of just one.

That's precisely where you want to use `set-replace!`:

	(set-replace! set new-pair new-pair)

will remove any existing pair that is equal to new-pair in the sense
of the comparator (presumably one created with `make-car-comparator`),
and replaces it with new-pair; or if there is no such pair, adjoins
new-pair to the set.  It's tailor-made for your application.

John Cowan          http://www.ccil.org/~cowan        cowan@xxxxxxxx
What has four pairs of pants, lives in Philadelphia,
and it never rains but it pours?
        --Rufus T. Firefly