How to print blank character in the Lisp format function?

lisp, whitespace

Solution

`If` takes three arguments: condition, then-form, else-form; the else-form is optional. Besides, I would use literal character syntax for literal characters.

(if (= (nth 0 list) 1)
    #\P
    #\Space)

Documentation:

Special form `if`

Character syntax

Character names

Problem

I hope there's someone to help me with this, because I can't find any useful answer, and I'm new with Lisp. What I'm trying to do is to test a value of one element and to print something if its 1, otherwise to print blank character. This works when all of the list arguments have the value 1: ``` (defun print-lst (list) (format t "~%~a ~a ~a~%" (if (= (nth 0 list) '1) '¦) (if (= (nth 1 list) '1) 'P) (if (= (nth 2 list) '1) '¦))) ``` so the output is `¦ P ¦`. But, if the second element in list is 0, it prints NIL on that place `¦ NIL ¦` and I want it to print a space instead `¦ ¦`(not just to skip that character`¦¦`, it is important to there is a blank character in that position in output line if the tested value is not 1). Is there any way to return a blank character if the condition `(if (= (nth 1 list) '1) 'P)` is not fulfilled or is there any other way to perform this? I hope I explained that nicely. Thank you.

Original source