Re: array initialisation
- From: tar@xxxxxxxxxxxxx (Thomas A. Russ)
- Date: 29 Apr 2008 14:05:27 -0700
nicolas.edel@xxxxxxxxx writes:
Suppose I define a class foo....
CL-USER> (defclass foo () ())
#<STANDARD-CLASS FOO>
Now I define a function that creates an array of instances of class
'foo.
CL-USER> (defun bar (x)
(make-array x :element-type 'foo :initial-element
nil))
I get a warning (that I could ignore) since NIL is indeed not an
instance of the FOO class.
How to create such an array with an initial value that allows me to
test whether one of its element has already been instanciated or not ?
Well, there's always:
(defconstant +NULL-FOO+ (make-instance 'foo))
(defun bar (x)
(make-array x :element-type 'foo :initial-element +NULL-FOO+))
(eq (aref (bar 10) 3) +NULL-FOO+)
--
Thomas A. Russ, USC/Information Sciences Institute
.
- References:
- array initialisation
- From: nicolas . edel
- array initialisation
- Prev by Date: Re: How to make a copy of a list
- Next by Date: Re: How to make a copy of a list
- Previous by thread: Re: array initialisation
- Next by thread: Re: array initialisation
- Index(es):
Relevant Pages
|