From: <bor...@ko...> - 2004-01-05 23:13:20
|
Hi Ken, Timothy | Your definition is wrong=2E Try this: | (define fact=20 | (let ((one (BigInteger=2E "1"))) | (lambda (n) | (if (=3D 0 (=2EintValue n))=20 | one | (=2Emultiply n (fact (=2Esubtract n one))))))) I feel ridiculous=2E=2E=2E=2E, I typed this quickly just to check whether BigInteger actually worked well before sending the email=2E =20 | >And then I had to stop the evaluation of (fact (BigInteger "1000"))=20 | >after 20 minutes on a 1=2E6GHZ, 512MB laptop=2E Scheme=20 | implementations that=20 | >I've played with in the past would return the result almost=20 | right away=20 | >on much slower machines=2E | > | >Anyway, the concern is really practical, not just for the=20 | sake of it=2E=20 | >I'm getting integer overflows while trying to solve a very practical=20= | >problem=2E |=20 | Have you tried using longs? No, I will=2E It may well work in my particular situation=2E=2E=2E=2EHowev= er, in InputPort=2EreadWholeNumber the U=2EtoNum(long) method is always invoked regardless of how the number is written=2E And that method will yield an Integer object whenever the constant is within the Java int range=2E Would= n't that matter in subsequent calculations? Again, I am only superficially familiar with the code, I just starated using Jscheme=2E | >If you have thought about this and have ideas about what to do, I am=20= | >willing to help with coding, testing etc=2E | > | >BTW, I think Jscheme is great! |=20 | Thanks! |=20 | I've been thinking there should be an extension library that=20 | would let you do this=2E Perhaps we can develop one=2E Here's a=20 | simple one that provides big integers and big rational=20 | numbers, i've been playing with=2E I think this makes sense, but only as a workaround=2E When typing gets so fine grained, and in a language without operator/function overloading, it becomes quite difficult to make a program evolve, reuse libraries with algorithms that one needs etc=2E I can't always know in advance whether I need a big integer, a long or a 32 bit value, I can't use a library writte= n with longs for my "big integer problem"=2E The fact that if I want to work= with, say, precisely 32-bit integers is really cool, but I shouldn't be forced to make that decision when I am not getting anything out of it=2E Perhaps there is a problem with the Java interfacing - those number type distinctions seem important only for that purpose=2E But probably a sensib= le method resolution can be easily found=2E Also, wasn't there a type casting= syntax in Jscheme for Java method invokation?=20 I would say that it makes sense to represent integers in Jscheme with a BigInteger whenever a Java modifier is not used in a number constant=2E Thanks for your responses! Best, Boris -------------------------------------------------------------------- mail2web - Check your email from the web at http://mail2web=2Ecom/ =2E |