Common lisp :KEY parameter use

前端 未结 3 530
心在旅途
心在旅途 2021-01-03 03:58

The :KEY parameter is included in some functions that ship with Common Lisp. All of the descriptions that I have found of them are unhelpful, and :KEY

3条回答
  •  孤街浪徒
    2021-01-03 04:21

    The :key argument is a function of one parameter; it is applied to each element of the sequence to generate the value used for testing. If omitted, the identity function is used.

    Here's an example from the CLHS:

    (member 2 '((1 . 2) (3 . 4)) :test-not #'= :key #'cdr) =>  ((3 . 4))
    

提交回复
热议问题