[Impromptu] vector behavour
Bruno Deferrari
utizoc at gmail.com
Fri Mar 20 16:26:25 GMT 2009
What happens if you build the vector dynamically?
Using '(vector 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)' instead of '#(1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0)'.
2009/3/20 David Smith <smithd at mail.com>:
> Hi all,
> Here is an interesting bit of information Impromptu users may find usefull:
>
> Persistance while using vectors works a bit differently.
> Normally, the let instantiates a new local variable for each call.
>
> (define countvar
> (lambda (val)
> (let ((v 1))
> (+ val v)
> )))
> (countvar 3) -> 4, every time
>
>
> If the variable is a vector, successive calls perform successive
> operations on the variable instansiated by let when the function is defined.
>
> (define inccvctr
> (lambda (vc)
> (let ( (v #(1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)))
> (math:vector-rotate v (- 0 vc))
> (print v) )))
>
> (inccvctr 1)->
>
> #(0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
> #(0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0)
> #(0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0)
> #(0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0)
> #(0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0)
> #(0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0)
>
> cheers,
> Dave
>
>
> --
> Be Yourself @ mail.com!
> Choose From 200+ Email Addresses
> Get a Free Account at www.mail.com!
> _______________________________________________
> Impromptu mailing list
> Impromptu at lists.moso.com.au
> http://lists.moso.com.au/mailman/listinfo/impromptu
>
>
More information about the Impromptu
mailing list