(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.Finally, I can get some primes on my laptop!
As a C++ enjoyer I can confirm this is some excellent idiomatic, readable C++ code.
typedef I<((I<((n::val (p::val))>::val) != (I<0>::val))> res;
};
There is some top class wizardry going on there! I don’t think I’ve ever used conditions in a type definition in C++ :)Update:
Ah, alright - so that evaluation logic is part of the template, not the code that eventually compiles.
It’s basically offloading some of the higher level language compiler logic to the templating engine. Honestly might be a better time investment than spending more time writing this in the parser.
Now I’m sort of intrigued and inspired to use C++ as a lowering target for elevate (a compiler framework I’ve been working on).
The rest is fantastic, and I'm glad it wasn't a typo.
> To run a C++ program, you'll need a C++ interpreter.
I thought 1. April is already over?