Re: who can do this without the recursion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, July 5, 2005 3:48 am, Jochem Maas said:
> I have a function which recursively loops an assoc array in
> order to build an HTML string containing hidden <input> elements
> that repesent the key/values passed in the array ... I know this can
> be done without recursion but I'm having a brainfreeze, anyone care
> to share some tips on replacing the recursion with some kind of stack
> based solution (the idea being that I want to remove the overhead
> of the recursive calls to the function if possible ...

I don't recall the answer, but if you Google for "eliminate tail
recursion" or "convert tail recursion to iteration" you should find
Computer Science textbook examples galore.

You'd think having done a zillion of these in my Grad School days would
have made more of an impression...

Mostly it impressed me that recursion wasn't "cool" -- just another "tool"
and one that you only should pull out 1% of the time.

I have a hacksaw.  I don't use it every meal.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux