chickadee » slset » slset-adjoin

slset-adjoin LIST SYM_1 ...procedure

Adds the SYM_i symbols not already in the LIST parameter to the result list. The result shares a common tail with the LIST parameter. The new symbols are added to the front of the list, but no guarantees are made about their order.

The LIST parameter is always a suffix of the result -- even if the LIST parameter contains repeated symbols, these are not reduced.

IMPORTANT: This is O(n+m) where n is the number of symbols already in LIST and m the number of symbols to adjoin. This is better than SRFI-1, but it does mean that if you adjoin symbols one by one (a typical situation), it is still O(n*m), just like SRFI-1.

If you know that the set cannot possibly contain the symbols to add, simply use cons to add them.

If you have no knowledge of the symbols and set contents, see reified-slsets below for O(1) set addition without duplicates.

(slset-adjoin '(a b c d c e) 'a 'e 'i 'o 'u) => (u o i a b c d c e)