strange error with mapcan and quote.
Posted: Sat Oct 20, 2012 1:54 pm
I get a weird behavior with sbcl when I try the following code at the repl.
Sbcl hangs at 100% CPU without returning an error.
Why do I get such a behavior?
Apparently, this is related to the quote '(even).
If I replace it by (list 'even), I get the expected answer (EVEN EVEN).
As far as I understand from the spec, the mapcan call should be equivalent to
but then this code gives a heap exhaustion. I am puzzled.
Code: Select all
(mapcan (lambda (x) (if (evenp x) '(even))) (list 1 2 3 4))
Why do I get such a behavior?
Apparently, this is related to the quote '(even).
If I replace it by (list 'even), I get the expected answer (EVEN EVEN).
As far as I understand from the spec, the mapcan call should be equivalent to
Code: Select all
(apply #'nconc (mapcar (lambda (x) (if (evenp x) '(even))) (list 1 2 3 4)))