Skip to main content

remf

remf Macro

Syntax:

remf place indicator → generalized-boolean

Arguments and Values:

place—a place.

indicator—an object.

generalized-boolean—a generalized boolean.

Description:

remf removes from the property list stored in place a property1 with a property indicator identical to indicator. If there are multiple properties1 with the identical key, remf only removes the first such property. remf returns false if no such property was found, or true if a property was found.

The property indicator and the corresponding property value are removed in an undefined order by destructively splicing the property list. remf is permitted to either setf place or to setf any part, car or cdr, of the list structure held by that place.

For information about the evaluation of subforms of place, see Section 5.1.1.1 (Evaluation of Subforms to Places).

Examples:

(setq x (cons () ()))(NIL) 
(setf (getf (car x) ’prop1) ’val1) → VAL1
(remf (car x) ’prop1) → true
(remf (car x) ’prop1) → false

Side Effects:

The property list stored in place is modified.

See Also:

remprop, getf

Expanded Reference: remf

Basic usage

remf destructively removes a property from a property list stored in a place. It returns true if the property was found and removed, or false otherwise.

(let ((plist (list :a 1 :b 2 :c 3)))
(values (remf plist :b) plist))
=> T
=> (:A 1 :C 3)

Removing a non-existent property

When the indicator is not present, remf returns NIL and the plist is unchanged.

(let ((plist (list :x 10 :y 20)))
(values (remf plist :z) plist))
=> NIL
=> (:X 10 :Y 20)

Successive removals

remf can be called multiple times to remove different properties.

(let ((plist (list :name "Alice" :age 30 :email "a@b.com")))
(remf plist :age)
(remf plist :email)
plist)
=> (:NAME "Alice")

Only the first occurrence is removed

When duplicate indicators exist, only the first one is removed.

(let ((plist (list :a 1 :b 2 :a 3)))
(remf plist :a)
plist)
=> (:B 2 :A 3)

Using with setf and getf

remf pairs naturally with getf and setf of getf for managing property lists.

(let ((plist '()))
(setf (getf plist :color) 'red)
(setf (getf plist :size) 'large)
(setf (getf plist :weight) 10)
(remf plist :size)
plist)
=> (:WEIGHT 10 :COLOR RED)