pushnew-elementsGBBopen Toolsremove-propertiespushnew/incf-aconsGoTo Top

pushnew/incf-acons   item increment place &key key test test-not => new-place-value[Macro]

Purpose
Increment by increment the value associated with item in an association list stored in place or add a new (item . increment) cons to the association list if there is no existing association for item.

Package   :gbbopen-tools

Module   :gbbopen-tools

Arguments and values

item     An object
increment     A number
place     A form which is suitable for use as a generalized reference
key     A function designator specifying a function object of one argument, or nil (default is nil)
test     A function designator specifying a function object of two arguments that returns a generalized boolean (default is #'eql)
test-not     A function designator specifying a function object of two arguments that returns a generalized boolean (use of :test-not is deprecated)
new-place-value     An association list

Returns
An association list (the new value of place).

See also
    push-acons
    pushnew-acons
    decf/delete-acons

Examples

  > (setf alist nil)
  nil
  > (pushnew/incf-acons 'x 1 alist)
  ((x . 1))
  > (pushnew/incf-acons 'x 1 alist)
  ((x . 2))
  > (pushnew/incf-acons 'y 2 alist)
  ((y . 2) (x . 2))
  > (pushnew/incf-acons 'x -1 alist)
  ((y . 2) (x . 1))
  > alist
  ((y . 2) (x . 1))
  >

Note
Declared numeric and pseudo probability versions of pushnew/incf-acons are also provided: pushnew/incf&-acons, pushnew/incf$&-acons, pushnew/incf$-acons, pushnew/incf$$-acons, pushnew/incf$$$-acons, and pushnew/incf%-acons.


The GBBopen Project


pushnew-elementsGBBopen Toolsremove-propertiespushnew/incf-aconsGoTo Top