Common lisp,未定义的交集函数行为?
根据 INTERSECTION 函数的 CLHS 条目 (http://www.lispworks.com/文档/HyperSpec/Body/f_isec_.htm):
对于满足测试的每一对,恰好是两个元素之一 该对中的哪一个将被放入结果中。
我的问题是我需要知道该对中的两个元素中的哪一个将被放入结果中,这在例如 :key #'car
时很重要用于提取要测试的参数,因为 cdr 可能不同。我想保证始终将第一个元素或始终将第二个元素放入结果中。我是否遗漏了某些内容,或者这只是未指定的行为,所以我不应该将它用于我的案例?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
intersection
根本无法提供您想要的保证;它实现了集合论交集与很多额外的功能,但只是没有那么额外。你必须自己动手。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.