home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!grebyn!pyrdc!gossip.pyramid.com!decwrl!elroy.jpl.nasa.gov!usc!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!nigel.msen.com!math.fu-berlin.de!zrz.tu-berlin.de!cs.tu-berlin.de!lenin!mfx
- From: mfx@cs.tu-berlin.de (lala)
- Newsgroups: comp.lang.scheme
- Subject: Re: Initializing vector elements
- Message-ID: <MFX.92Aug19102656@lenin.cs.tu-berlin.de>
- Date: 19 Aug 92 08:27:30 GMT
- References: <PK.92Aug19100516@talitiainen.cs.tut.fi>
- Sender: news@cs.tu-berlin.de
- Distribution: comp
- Organization: Technical University of Berlin, Germany
- Lines: 47
- In-Reply-To: pk@cs.tut.fi's message of Wed, 19 Aug 1992 08:05:16 GMT
-
- In article <PK.92Aug19100516@talitiainen.cs.tut.fi> pk@cs.tut.fi (Kellom{ki Pertti) writes:
- [...problems with make-vector...]
- Has there been discussion about what the second argument of
- make-vector should be? I would like to see make-vector to take a
- procedure that would be called for every element of the vector. Thus
- the example would be written as
-
- (define m (make-vector 10 (lambda () (make-vector 10 0))))
-
- This seems like a Scheme way of doing things. I know it is possibly
- too late to change it, but I thought I'd bring it up just for the sake
- of discussion.
-
- If anyone can prove me wrong by giving an elegant way of defining m
- within R4RS Scheme, I'll be delighted.
-
- You are nearly right -- IMHO, the Right Way is to give the init
- procedure the index of the element to create:
-
- (define m (make-vector 10 (lambda (i) (make-vector 10 0))))
-
- like, in,
-
- (make-vector 10 identity) => #(0,1,2,3,4,5,6,7,8,9)
-
- or,
-
- (make-vector 3 (lambda(x) (make-vector 3 (lambda (y)(if (= x y) 1 0)))))
-
- => #(#(1,0,0)
- #(0,1,0)
- #(0,0,1))
-
- --
- Pertti Kellom\"aki (TeX format) # These opinions are mine,
- Tampere Univ. of TeXnology # ALL MINE !
- Software Systems Lab # (but go ahead and use them, if you like)
-
-
- (Just my humble contribution to creeping featurism)
-
- Markus
- --
- Markus Freericks | email: mfx@cs.tu-berlin.de
- TU Berlin Sekr.FR 2-2 | phone: +49-30-314-21390
- Franklinstr.28/29 | priv.: +49-30-872523
- D-1000 Berlin 10 |"Inertia makes the world go 'round."
-