Comment on Interviews Can Be a Terrible Way to Identify Good ProgrammersparentComments−glogla14yOh boy.I seem to remember the (member 1 '(1 2 3)) -> t (equal '(1 2) '(1 2)) -> t (member '(1 2) '('(1 2) '(3 4))) -> nil bug. It took me just three hours, but boy was it annoying. In the end, it was just me not knowing the language of course.−wccrawford14yI can read just enough of that that it confuses me why it doesn't work. Care to explain?−glogla14yThe problem is, that (equal 1 1) -> t (equal '(1 2) '(1 2)) -> t (eq 1 1) -> t (eq '(1 2) '(1 2)) -> nil because eq tests for the same symbol, while equal test for the same list. Member uses eq, not equal.−eadvgf14yIf we are talking Common Lisp, the default test is actually EQL. ((eq 1 1) is not necessarily T).−wccrawford14yAh, I see. Thanks.
Comments
Oh boy.
I seem to remember the
bug. It took me just three hours, but boy was it annoying. In the end, it was just me not knowing the language of course.I can read just enough of that that it confuses me why it doesn't work. Care to explain?
The problem is, that
because eq tests for the same symbol, while equal test for the same list. Member uses eq, not equal.If we are talking Common Lisp, the default test is actually EQL. ((eq 1 1) is not necessarily T).
Ah, I see. Thanks.