Re: vector-push-extend



On Apr 5, 5:29 pm, p...@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon)
wrote:
Francogrex <fra...@xxxxxxxx> writes:
(let ((x (make-array 5 :fill-pointer 0)))
  (dotimes (i 10)
    (vector-push-extend (random 1.0) x)) x)

Result in SBCL:
#(0.5099975 0.008324027 0.001173377 0.77798724 0.24247074 0.97725177
  0.067973495 0.76105237 0.06009364 0.3982551)

In another implementation:
ERROR: The index, 5, too large.

Is this a normal result in the other implementation?

Yes.  Try:

(let ((size 10))
  (let ((x (make-array size :fill-pointer 0)))
    (dotimes (i size)
      (vector-push-extend (random 1.0) x)) x))

(or have a look at adjustable arrays).
--
__Pascal Bourguignon__http://www.informatimago.com

That works of course because size is the same; but your hint to
adjustable solved my original request which was the *extension*:

(let ((x (make-array 5 :fill-pointer 0 :adjustable t)))
(dotimes (i 10)
(vector-push-extend (random 1.0) x)) x)

works in the other implementation. It's funny though that SBCL seems
to have :adjustable t always turned on by default.
.



Relevant Pages

  • Re: managing large table of data
    ... SBCL list, but got no reply so far. ... OTOH few huge arrays should be OK. ... should take similar space (for short ones header is more ... General single floats should also take less ...
    (comp.lang.lisp)
  • Re: Does nobody want to discuss this?
    ... him as the micromanager that Carter has been accused of being, ... he still has a hint of the honor student about ... you think Michelle had to drop before their first kiss, ... it and found it funny, ...
    (rec.arts.comics.strips)
  • Re: Colbert does a "Pawlenty"
    ... promo films to inject some hint of sizzle into this pretty boring ... challenge with a great parody vid of his own: ... Good Lord that was funny. ...
    (rec.music.gdead)
  • Re: Exercise in finding truth
    ... Hint: ... a self professed web professional lives ... Now, Sandman, care to explain yourself - or will you just tell me that the ... it will be funny to see you try to substantiate that. ...
    (comp.sys.mac.advocacy)
  • Re: OT - News flash from Bush
    ... Funny. ... I'd written "(Hint: there's a CORPORATE media)" in my little ...
    (alt.sports.basketball.nba.la-lakers)