I'm currently implementing my own lisp interpreter. At the moment I working on the function nconc. I'm not sure how it should behave for the following cases:
Code: Select all
(nconc 1)
Code: Select all
(nconc nil 1)
regards,
Martin Kalbfuß
Code: Select all
(nconc 1)
Code: Select all
(nconc nil 1)
For your first code you apply the 3rd rule and[2] (nconc nil . lists) == (nconc . lists)
[3] (nconc list) => list
That's:The last list may be any object.
Code: Select all
(nconc 1) => 1
Code: Select all
(nconc nil 1) == (nconc 1) ;;; is equal to (nconc nil . (1)) == (nconc . (1))
(nconc 1) => 1
- edgarCLHS APPEND wrote:... The last argument is not copied; it becomes the CDR of the final dotted pair of the concatenation of the preceding lists, or is returned directly if there are no preceding non-empty lists.