Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z - Internet FAQ Archives

FAQ: Lisp Frequently Asked Questions 3/7 [Monthly posting]
Section - [3-4] After I NREVERSE a list, it's only one element long. After I SORT a list, it's missing things. What happened?

( Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Neighborhoods ]

Top Document: FAQ: Lisp Frequently Asked Questions 3/7 [Monthly posting]
Previous Document: [3-3] I used a destructive function (e.g. DELETE, SORT), but it didn't seem to work. Why?
Next Document: [3-5] Why does (READ-LINE) return "" immediately instead of waiting for me to type a line?
See reader questions & answers on this topic! - Help others by sharing your knowledge

These are particular cases of the previous question.  Many NREVERSE and
SORT implementations operate by rechaining all the CDR links in the list's
backbone, rather than by replacing the CARs.  In the case of NREVERSE, this
means that the cons cell that was originally first in the list becomes the
last one.  As in the last question, the solution is to store the result
back into the original location.

User Contributions:

Comment about this article, ask questions, or add new information about this topic: