decrement-list-members

Name

decrement-list-members -- Decrement each member of a list

Synopsis

(decrement-list-members vlist #!optional (decr 1) (floor 0))

Description

Decrement all the values of a list by decr, not to fall below floor.

vlist

The list of values. All the values of this list should be numeric.

decr

The amount by which each element of the list should be decremented. The default is 1.

floor

The value below which each member of the list is not allowed to fall. The default is 0.

Author

David Carlisle

Source Code

(define (decrement-list-members vlist #!optional (decr 1) (floor 0))
  ;; Decrement each member of a list
  (map (lambda (a) 
	 (if (<= a (+ decr floor))
	     floor
	     (- a decr)))
       vlist))