[plt-scheme] for-each in vector (macro)

From: f.michaudon at gmail.com (f.michaudon at gmail.com)
Date: Sun Apr 26 10:47:12 EDT 2009

Hello,
(define-syntax for-each-vector
  (syntax-rules ()
    ((for-each-vector proc vec) (let ((len (vector-length
vec)))
                                     (do ((index 0 (+ index 1)))
                                       ((= index len))
                                       (proc (vector-ref vec
index)))))))
Now examples:
(for-each-vector (lambda (a) (display a)) #( 1 2 3))

>>> 123 ok

(for-each-vector (lambda (a b) (display (+ a b))) #( 1 2 3)  #( 1 2
3))

>>> error syntax

I try to put some ... in my define doesn't work.
How to use multiple args in lambda ?


Posted on the users mailing list.