views:

113

answers:

1

There's a structure of the following format:

 (setq dist '(((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

+6  A: 

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.

Jerome
By the way, if you actually want a "reverse" assoc, i.e., find the pair where the CDR matches, there is RASSOC.
Svante