From: Caolan McNamara (Caolan.McNamara at domain ul.ie)
Date: Thu 28 Oct 1999 - 20:45:27 IST
On 28-Oct-99 John P . Looney wrote:
> Check this out.
>
> Into umb-scheme, type:
>
> (define (factorial number)(if (= number 0) 1 (* number (factorial (-
>number 1)))))
>
> then:
>
> (factorial 5500)
>
> How easy would it be to write a tcl, C or C++ function to get the
>factorial of 5500 ? Scheme rocks!
Reminds me of the horrors of using recursion in the real world. I
remember on co-op some moronic computer science character had
decided to write some bastardized linked list adder using recursion,
sure it works fine on those imaginary computers, but in the real world
embedded dos system that it went into it just *ATE* stack space, and
when adding something like the 300th entry if ran out of stackspace and
just barfed and died. A complete nightmare to find, coz theres nothing wrong
in the way of syntax, and with simple short test all would work fine, it
would only happen during a very long test, overnight in this case.
Luckily the idiot who had written it had left the company just a week
or so before I found this obscenity hidden away in the bowels of the
system. Never liked recursion after that. If theres any feasable non
recursion way of doing it, do that instead. Or stick a big static variable
into the middle of it and limit the depth of it to some known value, gagh!
C.
Real Life: Caolan McNamara * Doing: MSc in HCI
Work: Caolan.McNamara at domain ul.ie * Phone: +353-86-8790257
URL: http://www.csn.ul.ie/~caolan * Sig: an oblique strategy
Emphasise differences
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:48 GMT