|
|
|
|
|
by fexl
5744 days ago
|
|
OK, here's one more example of how to write a Fexl combinator. Back in 1924 the great Moses Schönfinkel demonstrated that all computable functions can be defined in terms of just two primitive functions: C (the constant function), and S (the fusion function). So here is the source code for S, the Mother of all functions: #include "node.h"
#include "type_S.h"
/*
Fusion function (Verschmelzungfunktion)
S x y z = ((x z) (y z))
*/
static void step(void)
{
int f1 = pop();
int f2 = pop();
int f3 = pop();
if (!f3) return;
set_pair(f3, P(R(f1),R(f3)), P(R(f2),R(f3)));
}
int type_S(void)
{
static int node = 0;
if (node == 0) node = new_combinator(step);
return node;
}
|
|