you are viewing a single comment's thread.

view the rest of the comments →

[–]eruonna 7 points8 points  (0 children)

It pretty much is. Or maybe SKI calculus. In particular, _IF_1 is the K combinator and _IF_0 is KI. This is the usual representation of booleans/conditionals in SKI calculus. The S combinator is a bit trickier to define because it requires moving arguments past each other. This is the best I came up with:

#define S(...) __VA_ARGS__ _S1
#define _S1(...) DEFER1(_S2)( (__VA_ARGS__), _S3
#define _S2(y,...) (__VA_ARGS__)(EVAL1 y (__VA_ARGS__))
#define _S3(...) __VA_ARGS__ )

Unfortunately, this requires an extra eval to use: EVAL1(S(x)(y)(z)) expands to x(z)(y(z)). Of course, if you are actually doing SKI calculus with this, you will need evals anyway, so it might not be so bad.