1

I'm new in LISP and trying to work with deep nested lists. All the basic functions with lists such as CONS or LIST do not give correct results. They replace part of the list by symbol #.

For example:

(list '(1 (2 (3 (4 (5))))) '(6 (7 (8 (9 (10))))))

=> ((1 (2 (3 #))) (6 (7 (8 #))))

Does anyone have an idea to fix this problem?

2 Answers 2

3

You can adjust the depth and length of what's printed by setting the variables *print-level* and *print-length*.
(It looks like your *print-level* is 4.)

Full documentation and examples are in the HyperSpec.

One of those examples:

 (setq a '(1 (2 (3 (4 (5 (6))))))) =>  (1 (2 (3 (4 (5 (6))))))
 (dotimes (i 8) 
   (let ((*print-level* i)) 
     (format t "~&~D -- ~S~%" i a)))
>>  0 -- #
>>  1 -- (1 #)
>>  2 -- (1 (2 #))
>>  3 -- (1 (2 (3 #)))
>>  4 -- (1 (2 (3 (4 #))))
>>  5 -- (1 (2 (3 (4 (5 #)))))
>>  6 -- (1 (2 (3 (4 (5 (6))))))
>>  7 -- (1 (2 (3 (4 (5 (6))))))
=>  NIL
Sign up to request clarification or add additional context in comments.

Comments

2

What you are seeing is the output being concatenated for brevity. The actual list is correct and not affected, but because it would be too long to print to the output, the lisp REPL shortens it when printing and uses # to indicate that it has done so.

2 Comments

Thank you for your fast answer. Just one more question: Is there any way to see the full output? It's necessary to checkout if the result is correct or not
It may also help to set *print-circle* to nil, but only ever do this if you're sure there are no circular structure sharing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.