5 ms·
I believe racket/stream uses memoization. So it should be as fast as any memoized fibbonaci function.
by pubby 5y ago
I believe racket/stream uses memoization. So it should be as fast as any memoized fibbonaci function.
- exdsq 5y agoI'll have to test this because it's much faster than I remember Python achieving with memoization.
- sgtnoodle 5y agoPresumably python is 10-100 times slower than compiled machine code, so that's not too surprising?
- exdsq 5y agoI'm not running compiled code, am I? If I just run 'racket ./filename.rkt' it's interpreted? This is why I'm so amazed - it's uncompiled code running at speeds I'd expect from C, not an 'academic' Lisp. Edit: I see someone else describes how it compiles JIT so I see your point. Slightly less magic than I thought :)
- soegaard 5y agoIn that case the file is first compiled then run. You can compile it first with: racket make filename.rkt And then run it: racket filename.rkt
- rajandatta 5y agoI don't believe Racket uses Memoization automatically. You can certainly use it easily enough but that's a user decision.