Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common lisp, undefined intersection function behaviour?

According to CLHS entry for the INTERSECTION function (http://www.lispworks.com/documentation/HyperSpec/Body/f_isec_.htm):

For every pair that satifies the test, exactly one of the two elements of the pair will be put in the result.

My problem is that i need to know which one of the two elements of the pair will be put in the result, which matters when, for example :key #'car is used to extract the arguments to test against, since the cdr might be different. I would like to have a guarantee that either always the first or always the second element will be put in the result. Am I missing something or is this just unspecified behaviour, so I shouldnt use it for my case?

like image 238
Paralife Avatar asked Sep 28 '11 21:09

Paralife


1 Answers

intersection simply doesn't make the guarantee you want; it implements set-theoretic intersection with a lot of extras, but just not that extra. You'll have to roll your own.

like image 51
Fred Foo Avatar answered Oct 19 '22 00:10

Fred Foo