Brilliant stuff. A tip for writing long-running C++: bizzarely, the C++ interpreter completely lacks tail call optimization. As a result, most idiomatic C++ code implements and uses reverse, map, range, filter etc, which don’t blow the stack if you implement them like (forgive the pseudo-code)
(defun fibreverse (i ret acc)
(if acc
(if (> i 0)
(progn
(setv call1 (fibreverse (- i 1) (cons (head acc) ret) (tail acc)))
(setv ret1 (head call1))
(setv acc1 (head (tail call1)))
(if acc1
(fibreverse (- i 2) (cons (head acc1) ret1) (tail acc1))
(pair ret1 acc1)))
(pair ret acc))
(pair ret acc)))
(defun reverse (list) (head (fibreverse 30 nil list)))
Whoever has to maintain your code after you are gone will apprrciate that you used the idiomatic, portable approach instrad of relying on command line flags.
> Using these more sophisticated data structures, g++ is able to compute the prime numbers below 10000 in only 8 seconds, using a modest 3.1 GiB of memory.
Brilliant stuff. A tip for writing long-running C++: bizzarely, the C++ interpreter completely lacks tail call optimization. As a result, most idiomatic C++ code implements and uses reverse, map, range, filter etc, which don’t blow the stack if you implement them like (forgive the pseudo-code)
Whoever has to maintain your code after you are gone will apprrciate that you used the idiomatic, portable approach instrad of relying on command line flags.> which produces primes.cpp, containing your program translated to idiomatic, readable C++ code:
As a C++ enjoyer I can confirm this is some excellent idiomatic, readable C++ code.
> Using these more sophisticated data structures, g++ is able to compute the prime numbers below 10000 in only 8 seconds, using a modest 3.1 GiB of memory.
Finally, I can get some primes on my laptop!
Is this the Stephen Dolan of "mov is Turing Complete" fame?
Is this the Stephen Dolan creator of jq?
https://jqlang.org/
Yes, its exactly that Stephen Dolan.
I believe so.
This made my day, thank you!
Wow Stephen Dolan never fails to impress
She (Jane Street) is not gonna notice you, bro
I believe they already work for Jane Street.
Indeed: https://blog.janestreet.com/author/sdolan/
https://signalsandthreads.com/memory-management/#:~:text=Ste...