#include <stdio.h>
#define DX 0.0001
#define DERIV(_f) float deriv_##_f(float x) { return (_f(x + DX) - _f(x)) / DX; }
float cube(float x) { return x * x * x; }
DERIV(cube)
int main(void) {
printf("%f\n", deriv_cube(2));
printf("%f\n", deriv_cube(3));
printf("%f\n", deriv_cube(4));
}
Any language supporting closures or generics could get rid of the unsexy DERIV macro.What sets Lisp apart is its "code as data" approach which lets the coder write incredibly powerful macro (and also incredibly hard to understand code). The rest can easily be emulated in other languages.
I do like this naive approach mind you, there's a certain Zen to be found reimplementing these mathematical concepts from first principles, I just really fail to see what makes Lisp so remarkable in this context.