It struck me recently that I tend to think of parameters as O(1) when in
reality they're O(n), where n is the number of frames on the stack,
right?  I was considering writing some code that cons'ed itself on its
natural recursion, but in the process was checking the parameter.
But then I realized it would be O(n^2) in the sense that it's the number
of steps of the application times the number of frames on the stack...
right?

Due to that reason, I figured the following code would absolutely trash
my computer:

 (let ([limit-param (make-parameter 1000000)])
   (let lp ([n 1])
     (if (= n (limit-param))
         '()
         (cons n
               (lp (add1 n)))))
   (void))    ; return void just to avoid printing that all out

Nope, runs almost instantaneously.

What's going on?  It's nice to see my computer *not* trashed, but now
I'm unsure about my understanding of how parameters work.

 - Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to