Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Iteration vs. Recursion

Name: Anonymous 2008-08-04 16:54

Iteration obviously, unless your algorithm can't possibly be implemented any other way.

Name: Anonymous 2008-08-06 9:04

>>39
I don't think so Tim. Optimizing tail recursion can get rid of the overhead but it won't magically turn your recursive algorithm into an iterative one. I know because Sussman told me so.

Name: Anonymous 2008-08-06 9:08

In OCaml tail recursive is often way faster than iterative, so go suck a fuck you fags.

Typical of /prog/ shooting your mouth off.

Name: Anonymous 2008-08-06 9:51

...

An iterative solution is often completely different from the recursive solution. >>15 is a shitty iterative prefix tree traversal -- the recursive variant looks like this:

def traverse( node, func ):
    if not func: return
    func( node )
    traverse( node.left, func )
    traverse( node.right, func )


It doesn't use tail recursion. It can't use tail recursion. In order to avoid raping the fuck out of your stack, you must use an iterative approach like the one above.

Tail recursion is the same goddamn thing as an iterative approach -- any tail recursive function can be wrappered into a loop which does the same thing (and this is what any self-respecting compiler does for you), and any iterative loop can be restructured into a tail-recursive function. A true recursive function (qsort, tree traversal, etc) is such that it is not tail recursive, but rather, branches out.

Name: Anonymous 2008-08-06 10:42

>>43
The Erlang VM seems to get along just fine with optimizing deep recursive loops without the typical "tail recursive only!" constraints.

Name: Anonymous 2008-08-06 10:59

tail recursion is overrated.

Name: Dr Sigmund Freud 2008-08-06 10:59

>>44
You want to fuck your mother.

Name: Anonymous 2008-08-06 11:04

>>44
That's fine. My main point was that tail recursion == iteration and that the question posed in >>1 was somewhat deeper than that.

Also fuck yeah Erlang.

Name: Anonymous 2008-08-08 1:46

>>1
http://cgi.cse.unsw.edu.au/~dons/blog/2008/05/16
Recursion is the spell choice of wizards.

Name: Anonymous 2008-08-12 12:49

>>48
Don't EVER link to dons

Name: Anonymous 2008-08-20 0:40

bump

Name: Anonymous 2008-08-20 1:47

from the contents of the posts in this thread I can tell you who is a Nigger and who is a human.

Name: Anonymous 2010-12-21 10:58

Name: Anonymous 2013-09-01 15:11


The formula would be useful neither to compute the force between two objects of finite mass nor to compute their motions. If an infinite mass object were to exist, any object of finite mass would be attracted with infinite force (and hence acceleration) by the infinite mass object, which is not what we can observe in reality.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List