[Impromptu] vector behavour

David Smith smithd at mail.com
Fri Mar 20 16:01:42 GMT 2009


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.moso.com.au/pipermail/impromptu/attachments/20090320/10c26d66/attachment.htm 


More information about the Impromptu mailing list