← Back to Reference Manual Index
Core LispBM
Setref
# LispBM Set Extensions Reference Manual

The set extensions provide operations for working with sets represented as lists of unique elements. These extensions may or may not be present depending on the platform and configuration of LispBM.

Set Operations

member

member checks if a value is an element of a list. The form of a member expression is (member value list). Returns list if value is found anywhere in it, or nil if not found. Equality is tested structurally in the same way as eq, so number types must match. Note that member is part of core LispBM and is always available.

Example Result
(member 3 (list 1 2 3))
(1 2 3)
(member 3u (list 1 2 3))
nil
(member 'x (list 'a 'b 'x 'y))
(a b x y)
(member 'z (list 'a 'b 'x 'y))
nil

set-insert

set-insert inserts a value into a set. Sets are represented as lists with no duplicate elements. The form of a set-insert expression is (set-insert set value). If value is already a member of set the original set is returned unchanged. Otherwise a copy of the set is returned with value appended. Membership is tested using structural equality.

Example Result
(set-insert nil 1)
(1)
(set-insert (list 1 2 3) 4)
(1 2 3 4)
(set-insert (list 1 2 3) 2)
(1 2 3)

set-union

set-union computes the union of two sets. Sets are represented as lists with no duplicate elements. The form of a set-union expression is (set-union set1 set2). Returns a set containing all elements from both set1 and set2 with no duplicates. Membership is tested using structural equality.

Example Result
(set-union (list 1 2 3) (list 4 5 6))
(4 5 6 1 2 3)
(set-union (list 1 2 3) (list 2 3 4))
(2 3 4 1)
(set-union nil (list 1 2 3))
(1 2 3)

This document was generated by LispBM version 0.36.0