From: Geoffrey K. <ge...@kn...> - 2003-08-08 10:35:55
|
Never mind, I guess that was a silly question. For now I've done this: (define (pick-one v) (vector-ref v (.nextInt random-gen (vector-length v)))) On Friday, Aug 8, 2003, at 00:00 US/Eastern, Geoffrey Knauth wrote: > Let's say I have: > > (define (stone-size) > (vector-ref stone-sizes > (.nextInt random-gen (vector-length stone-sizes)))) > (define (stone-thickness) > (vector-ref stone-thicknesses > (.nextInt random-gen (vector-length stone-thicknesses)))) > (define (caulking-type) > (vector-ref caulking-types > (.nextInt random-gen (vector-length caulking-types)))) > > Notice the repetition? How can I use a JScheme macro to write this > once? Ignore the fact that "es" pluralizes "thickness" while "s" > pluralizes "size" and "type." > > Thanks, > Geoffrey |