in reply to Re^11: Specializing Functions with Currying
in thread Specializing Functions with Currying

I am not sure what you are trying to prove with this benchmark. Of course factorial_r_extra will take longer, it creates my $x = "blah" x 100 5,000,000 times, as opposed to factorial_i_extra which only creates it 100,000 times. That proves nothing about the inefficiency of recursion in perl, only that it takes longer to do something 50 times more, which is true regardless of whether you use iteration or recursion.

-stvn

Replies are listed 'Best First'.
Re^13: Specializing Functions with Currying
by itub (Priest) on Aug 07, 2004 at 02:35 UTC
    How fitting that a discussion about recursion gets to over 12 levels of depth! ;-)

    I must say that I'm surprised that the difference between recursion and iteration is as small as it is in this case. The problem I have had in some cases, though, is that perl starts to complain about deep recursion when I try recursive algorithms that go just one or two thousand levels down...

      How fitting that a discussion about recursion gets to over 12 levels of depth! ;-)

      I will see your 13, and take it one more level down ;- )

      The problem I have had in some cases, though, is that perl starts to complain about deep recursion when I try recursive algorithms that go just one or two thousand levels down...

      FWIK, Perl's deep recursion error is a somewhat arbitrary number (I think its actually set to 1000), and has no real bearing on perl's ability to keep recursing (which is only limited to the physical resources (memory/CPU/disk-swap) available for it to consume). And I believe that someone once told me you can easily change that number and recomplile perl if you need more.

      -stvn
        It is 100. grep for sub_crush_depth.