On 2023-08-18 02:33, Bakul Shah wrote:
On Aug 16, 2023, at 1:40 PM, Torbjörn Svensson Diaz torbjorn_svensson_diaz@yahoo.com wrote:
This is exactly the same (except for indentation) as what I posted on HackerNews a few months ago: https://news.ycombinator.com/item?id=35021745
I don't recall but I may have posted it elsewhere too! This version has no globals compared to the version I posted on May 23, 2013 on a RaspberryPi forum but basically the same.
You have indeed posted it elsewhere, more precisely at the FreeBSD forums. Here's a link, https://forums.freebsd.org/search/332332/?q=chudnovsky&o=date.
||| |
|There's a C version of the same algorithm that is about sixteen times as long, so Scheme is expressive indeed. What I want to do is to compare the two implementations, ||but I get stuck and don't know how to proceed!|
Do you mean Compare the scheme code with the C code? If so, you'd have understand the main part of the function above. For that I think your best bet may be to start with the wikipedia article: https://en.wikipedia.org/wiki/Chudnovsky_algorithm
And understand the recurrence form. But if you just want to compare their overall resource use and timing, don't bother!
I think you're right. I should start with some simpler algorithm that's easier to understand and tinker with it instead. I'm just a Scheme novice.
|First I want to write a version of the Scheme program that asks me how many digits I want to calculate and then calculate that using interpretation, but I don't manage to do that. Then I want to compile the Scheme code and see how fast it runs and how much RAM it uses. Lastly, I want to compile the C version and run it. I want to compare the performance and RAM usage in all three cases. |
|Could you please help me out with the Scheme part? I guess I am supposed to use "read" somehow, but how? I am a Scheme novice.
'supposed to use "read" somehow' -- This does sound like homework but this is the easy part. Look at some interactive Scheme program. Alternatively pass the number of digits as an argument. I don't think *compiling* the Scheme program would help much for performance.
It's not homework. Basically no schools teach Scheme anymore.
I am still not clear on why you want do all this though!
Just want to learn Scheme and see if it's as good as some people say it is. That's all!