[plt-scheme] for-each in vector (macro)
usage of lambda is true.You can use lambda like that.
I try
(lambda (a b) (display (+ a b))) #( 1 2 3) #( 1 2 3)
output :
(lambda (a1 a2) ...)
(vector 1 2 3)
(vector 1 2 3)
Also
i dont know any built in fuction that works in vector but i try your lambda
with map.
> (map (lambda (a b) (display (+ a b))) '( 1 2 3) '( 1 2 3))
246(list (void) (void) (void)) // reason of (list (void) (void) (void)) is
display method because display`s return type is vpid.
your mistake is in for-each-vector
for-each-vector: bad syntax in: (for-each-vector ((lambda (a b) (display (+
a b))) #(1 2 3) #(1 2 3)))
You should focus on your function.I dont know how to write method with
define-syntax but you mistake is in your function.
Note : You can use lambda with these two option
Either (lambda (a b c d e f g h)
Or (lambda (a) (lambda(b) (lambda(c) (lambda (d)
(lambda(e)(lambda(f).....))))
2009/4/26 François Michaudon <f.michaudon at gmail.com>
> 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 ?
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090426/c03369e5/attachment.html>