[hunchentoot-devel] Hunchentoot Recursive Function

Phil Marneweck zaries at global.co.za
Wed Dec 16 13:19:16 UTC 2009


Thanx I got the same answer on #lisp 

For some reason I only received this mail an hour after you actually
sent it, thus my latter posts...appologize to the group as a whole for
that. I was not ignoring answers on the mailing list I just did not get
them until to late.


On Wed, 2009-12-16 at 17:34 +0530, Chaitanya Gupta wrote:
> Phil Marneweck wrote:
> > This is most likely a problem with my understanding of lisp and not
> > hunchnetoot.
> > 
> > Why does the following function only out put "Recursive count- 0" to the
> > hunchentoot page?
> > 
> 
> This might be more of an issue with your understanding of CL-WHO rather 
> than Lisp ;)
> 
> (defun recursive-test (count)
>    (with-html-output (*standard-output*)
>      (if (< count 10)
>          (recursive-test (+ count 1)))
>      (str (format nil "Recursive count- ~A~%" count))))
> 
> Note that I am using WITH-HTML-OUTPUT instead of 
> WITH-HTML-OUTPUT-TO-STRING. This way, output by all recursive calls 
> would go to *standard-output* which is then be handled by TEST-RECURSIVE.
> 
> (define-easy-handler (test-recursive :uri "/test.html") ()
>    (with-html-output-to-string (*standard-output*)
>      (recursive-test 0)))
> 
> We don't need the (STR ...) around (RECURSIVE-TEST 0) since we are not 
> interested in the return value. Also, you don't necessarily need to use 
> WITH-HTML-OUTPUT-TO-STRING here -- even WITH-OUTPUT-TO-STRING would work.
> 
> Chaitanya
> 
> > (defun recursive-test (count)
> >   (with-html-output-to-string (*standard-output*)
> >     (if (< count 10)
> >         (recursive-test (+ count 1)))
> >     (str (format nil "Recursive count- ~A" count))))
> > 
> > (define-easy-handler (test-recursive :uri "/test.html" () 
> >     (with-html-output-to-string (*standard-output*)
> >       (str (recursive-test 0))))
> > 
> > 
> > _______________________________________________
> > tbnl-devel site list
> > tbnl-devel at common-lisp.net
> > http://common-lisp.net/mailman/listinfo/tbnl-devel
> > 
> 
> 






More information about the Tbnl-devel mailing list