I am trying to print the value of an array in CLISP, I wrote below function:
(setq x (make-array '5 :initial-contents '(a b c d e)))
(loop for i from 0 to 4 do (write aref x i))
But I am getting error
*** - PROGN: variable AREF has no value
The following restarts are available:
USE-VALUE :R1 Input a value to be used instead of AREF.
STORE-VALUE :R2 Input a new value for AREF.
I am totally new to CLISP and not getting why I am getting the above error.
AREF
is a function, not a variable.
You are missing a set of parentheses around it: (aref x i)
:
(loop for i from 0 to 4 do (write (aref x i)))
or just
(loop for e across x do (write e))
PS. Note that write
is a
relatively low level function.
You probably want to use a variant of print
or princ
.