Hi, I tried doing this:
(setf n 30)
(setf new-array (make-array (n 10)))
;;compiler thinks (n 10) is a function
SO HOW CAN I make an array whose atleast one dimension is taken from
the value of a variable 'n'.
NOTE: One can make a uni-dimensional but not multi-dimensional!!
eg. (setf new-array (make-array n)) ;; is fine.
Thanks for any replies.
From: Simon Leinen
Subject: Re: How to make multi-dimensional arrays with var. dimension??
Date:
Message-ID: <SIMON.91Jul8104946@liasun1.epfl.ch>
In article <·····················@newserve.cc.binghamton.edu>
······@bingvaxu.cc.binghamton.edu writes:
(setf n 30)
(setf new-array (make-array (n 10)))
;;compiler thinks (n 10) is a function
SO HOW CAN I make an array whose atleast one dimension is taken from
the value of a variable 'n'.
You should have said
(setf new-array (make-array (list n 10)))
I'd recommend reading ((the first sections of) chapter 5 of) Common
Lisp, the Language by Guy L. Steele.
--
Simon.