Re: Newbie problem: naked left-hand reference
"Victor Rodriguez" <[email protected]> Thu, 19 Apr 2007 15:37:34 -0400
| Newsgroups | gmane.comp.java.sisc.user |
|---|---|
| Message-ID | <[email protected]> |
On 4/19/07, Kjetil S. Matheussen <[email protected]> wrote: > On Thu, 19 Apr 2007, Jon Kleiser wrote: > ... > is another way of writing > > (let loop ((i m)) > (letrec ((i2 (* i i)) > (ds (desc-series i2))) > ...)) > > which gives undefined behaviour because you shouldn't reference already > defined variables in variables in a letrec block. (Hmm, that was probably > a bad explanation). Anyway, the reference to "i2" is the problem, since > its defined elsewhere in the letrec. I do not really understand the explanation. Here is a way to solve the problem (and better style, IMO): (define do-from-to (lambda (m n) (let loop ((i m)) (let* ((i2 (* i i)) (ds (desc-series i2))) (display ds) (newline) (if (= i n) 'done (loop (+ i 1))))))) Best Regards, Victor Rodriguez. > > > > I also have another question: > > What's the easiest way to meassure how long a part of a sisc program takes > > to execute? > > > > The time function, perhaps... I use this macro: > > (define-macro (c-time expr) > `(cadr (time (eval ',expr)))) > > (c-time (do-from-to 2 4)) > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Sisc-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/sisc-users > ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/