From: Andrew Lentvorski <[EMAIL PROTECTED]>
Gabriel Sechan wrote:
If you have to get your head around it, by definition its not intuitive.
Iteration is far from intuitive, IMO. We are *taught* iteration far
earlier.
For a very large value of far earlier- we're taught iteration in childhood,
because its a more real world way of looking at things. Want to wash all
the dishes? Well, wash dish 1, wash dish 2, wash dish 3, and so on. Humans
seem to be hard wired to think in this way- iterate over objects.
In addition, as I have pointed out. "Recursion" isn't necessarily the win
over iteration. It's the existence of "foreach/map/apply/collect" in the
language that is the big win.
Foreach always seemed to me to be a form of iteration, not recursion. And
for some reason I've never really liked map. It might be due to me
associating it with perl though- I almost always see it in perl, meaning
its usually written in perlese, including liberal use of $_ and other
cryptic variables.
And I've seen far more bugs in recursive versions of algorithms than the
equivalent iterative ones.
IMO, it depends. Certain algorithms lend themselves to iteration and
certain algorithms lend themselves to recursion.
People who do "tree" algorithms iteratively often screw them up horribly.
People who do multiple action "foreach" recursively often screw them up
horribly.
Agreed. I work with trees constantly in my current job (the service I
provide is basicly a graph data service). When I work on hierarchial data,
I recurse. When I'm given a list of nodes or edges, I iterate. It just
feels more natural and easier to code in both cases.
Gabe
_________________________________________________________________
Picture this share your photos and you could win big!
http://www.GETREALPhotoContest.com?ocid=TXT_TAGHM&loc=us
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg