euslisp / EusLisp

EusLisp is an integrated programming system for the research on intelligent robots based on Common Lisp and Object-Oriented programming. [Manual](http://euslisp.github.io/EusLisp/manual.html ) [マニュアル](http://euslisp.github.io/EusLisp/jmanual.html )
Other
57 stars 50 forks source link

[Needs discussion] Fix assoc :key behavior #450

Open Affonso-Gui opened 4 years ago

Affonso-Gui commented 4 years ago

EusLisp have the non-standard behavior of applying assoc's :key argument on each form, instead of on each of its car values:

eus$ (assoc 3 '((1 . "one") (2 . "two") (3 . "three")) :key #'print)
(1 . "one")
(2 . "two")
(3 . "three")
;; nil

sbcl$ (assoc 3 '((1 . "one") (2 . "two") (3 . "three")) :key #'print)
1 
2 
3 
;; (3 . "three")

This PR implements the standard :key argument behavior in EusLisp as well.

eus$ (assoc 3 '((1 . "one") (2 . "two") (3 . "three")) :key #'print)
1
2
3
;; (3 . "three")

This is not backward compatible, but I am opening it because Inaba-sensei has pointed the EusLisp behavior as a bug (https://github.com/euslisp/EusLisp/issues/436), granted that 'nobody is using this in code' and asked for a PR. @inabajsk