chickadee » slset » with-reified-slset

with-reified-slset LST PROCprocedure

Calls PROC with a reified slset object referring to LST as its argument. During the dynamic extent of PROC, all symbols in LST will have an observable marking in their plist.

A call to with-reified-slset is O(n) on the length of LST.

After PROC returns, with-reified-slset returns multiple values:

The first value is the final slset that remains after applying all mutations to the original LST. The rest of the values are the values returned by PROC, allowing one to capture return values from PROC if desired.

Note that most continuations which accept a single value will implicitly discard any extra values, so if you're not interested in what PROC returns, you may act exactly as if with-reified-slset only returned the final slset.

   (let-values ((result (with-reified-slset '(a b c d a c e)
                          (lambda (r)
                            (reified-slset-contains? r 'a) => #t
                            (reified-slset-contains? r 'i) => #f

                            (reified-slset-delete! r 'b) => r
                            (reified-slset->slset r) => (a c d a c e)

                            (reified-slset-adjoin! r 'x) => r
                            (reified-slset-contains? r 'x) => #t

                            (reified-slset-delete! r 'a 'e 'i) => r
                            
                            (reified-slset->slset r) => (x c d c)

                            (reified-slset-contains? r 'a) => #f

                            (reified-slset-contains? r 'c) => #t

                            ;; Return some values
                            (values 1 2 3)))))
     result) => ((x c d c) 1 2 3)