This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bracket heresies. What about subscripting?


Chris Bitmead <chris@tech.com.au> writes:

> > (vector-ref v n) is a very clumsy way of getting element n in a 
> > vector v; I am still enough of C/Pascal/Basic person at heart 
> > to have to stop myself from saying v[n].
> 
> If you were writing nice functional code I don't think you'd be using
> vectors as a data structure very much. Better make that two icy cold
> showers and a full weekend of SICP :-).

Anders Sandberg and I have written a small example matrix library in
Goops.

There we write

  (m i j) ; reference element i,j in m.

  (* m m) ; multiply m by itself

  (set! (m i j) 17)		 ; assign 17 to element i,j in m
  (set! (a (.. 1 m) (.. 1 n)) b) ; set the m x n block in upper left
                                 ; corner of a to b

This is possible since objects of Goops also can be operators.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]