开发者

Association in Common Lisp

开发者 https://www.devze.com 2022-12-13 03:38 出处:网络
There\'s a structure of the following format: (setq dist 开发者_如何学Python\'(((1 1) 1) ((0 2) 3)

There's a structure of the following format:

 (setq dist 开发者_如何学Python'(((1 1) 1)
              ((0 2) 3)
              ((1 2) 1)
              ((2 3) 3)
              ((3 5) 4)))

Is there any function which, if I call

(myf '(0 2))

could give me

3

or

((0 2) 3)

Something like a reverse assoc


I fail to see why this would be called a reverse ASSOC.

(assoc '(0 2) dist :test #'equal)
> ((0 2) 3)

It looks like ASSOC works fine, provided you change the test function, so that lists used as keys are correctly tested.

0

精彩评论

暂无评论...
验证码 换一张
取 消