From: ·······@cad.strath.ac.uk
Subject: Q: Array start with zero.. how can I prevent?
Date: 
Message-ID: <91deab$1c2$1@nnrp1.deja.com>
Hello,

Sorry about too many questions.
Following example always gives me the array which start with zero.
e.g.,

5 > test-arr-1 #(0 0.5026636655120098  0.8247561327016124 
0.07244224168507496  0.5  0.5  0.4511254960556048  1  0.5672687988234983 
0.29207520459513625  0.5577158767526089  0.24721137396902604)

The first zero is not the result of calculation, and I don't need that value.
I think it happen because I actually push a new element from second index (1).
But I don't know how can I put new element from the first index....
I tried to modify the fill-pointer or array number, but it doesn't works. ;(
How could I put an element from the first index?
Thanks for your help.

Sungwoo


;--------------------------------------------------------------------
(setf test-num 14)
(defun test ()
  (test-arr number)
  (loop for i from 0 to 100
           when (something-happened)
           do (vector-push-extend test-num test-arr)
                (vector-push-extend (* test-num 0.5) test-arr)))

(defun test-arr (number)
  (setf test-arr-1 (make-array (list (+ number 1))
                                              :adjustable t
                                              :fill-pointer 1))
  (setf test-arr-2 (make-array (list (+ number 1))
                                              :adjustable t
                                              :fill-pointer 1)))


Sent via Deja.com
http://www.deja.com/

From: Joe Marshall
Subject: Re: Q: Array start with zero.. how can I prevent?
Date: 
Message-ID: <elz9aaaz.fsf@content-integrity.com>
·······@cad.strath.ac.uk writes:

> Hello,
> 
> Sorry about too many questions.

Don't worry about it, you seem to be making good use of the answers.

> Following example always gives me the array which start with zero.
> e.g.,
> 
> 5 > test-arr-1 #(0 0.5026636655120098  0.8247561327016124 
> 0.07244224168507496  0.5  0.5  0.4511254960556048  1  0.5672687988234983 
> 0.29207520459513625  0.5577158767526089  0.24721137396902604)
> 
> The first zero is not the result of calculation, and I don't need that value.
> I think it happen because I actually push a new element from second index (1).
> But I don't know how can I put new element from the first index....
> I tried to modify the fill-pointer or array number, but it doesn't works. ;(
> How could I put an element from the first index?
> Thanks for your help.


The problem is when you make the array, you set the 
:fill-pointer to 1.

You want to set it to zero because it contains the index of the first
*unused* element (or you could say it holds the number of used
elements). 



> 
> Sungwoo
> 
> 
> ;--------------------------------------------------------------------
> (setf test-num 14)
> (defun test ()
>   (test-arr number)
>   (loop for i from 0 to 100
>            when (something-happened)
>            do (vector-push-extend test-num test-arr)
>                 (vector-push-extend (* test-num 0.5) test-arr)))
> 
> (defun test-arr (number)
>   (setf test-arr-1 (make-array (list (+ number 1))
>                                               :adjustable t
>                                               :fill-pointer 1))
>   (setf test-arr-2 (make-array (list (+ number 1))
>                                               :adjustable t
>                                               :fill-pointer 1)))
> 
> 
> Sent via Deja.com
> http://www.deja.com/


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----
From: ·······@cad.strath.ac.uk
Subject: Re: Q: Array start with zero.. how can I prevent?
Date: 
Message-ID: <91dknr$7bg$1@nnrp1.deja.com>
 > Don't worry about it, you seem to be making good use of the answers.

Thanks for your encourager. =)

> The problem is when you make the array, you set the
> :fill-pointer to 1.
>
> You want to set it to zero because it contains the index of the first
> *unused* element (or you could say it holds the number of used
> elements).

I am silly enough... ;)
Actually I did that exactly same thing as you mentioned.
But at that time, it didn't work....
I think maybe I didn't compile properly after modified.
Anyway, thanks alot.  =)

Sungwoo


Sent via Deja.com
http://www.deja.com/