Last active
August 29, 2015 13:56
-
-
Save Kontinuation/9023284 to your computer and use it in GitHub Desktop.
SKI combinators generated by MetaLang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "metalang.hpp" | |
struct I { | |
template <typename x, typename _0> | |
struct apply { | |
typedef x value; | |
}; | |
}; | |
struct K { | |
template <typename x, typename _1> | |
struct apply { | |
struct __lambda_2{ | |
template <typename y, typename _2> | |
struct apply { | |
typedef x value; | |
}; | |
}; | |
typedef __lambda_2 value; | |
}; | |
}; | |
struct S { | |
template <typename x, typename _2> | |
struct apply { | |
struct __lambda_3{ | |
template <typename y, typename _3> | |
struct apply { | |
struct __lambda_4{ | |
template <typename z, typename _4> | |
struct apply { | |
typedef typename x::template apply<z, __dummy_arg>::value::template apply<typename y::template apply<z, __dummy_arg>::value, __dummy_arg>::value value; | |
}; | |
}; | |
typedef __lambda_4 value; | |
}; | |
}; | |
typedef __lambda_3 value; | |
}; | |
}; | |
typedef K T; | |
typedef S::apply<K, __dummy_arg>::value F; | |
typedef F::apply<T, __dummy_arg>::value NOT; | |
typedef T OR; | |
typedef F AND; | |
struct SKI2Int { | |
template <typename n, typename _3> | |
struct apply { | |
struct __lambda_4{ | |
template <typename x, typename _4> | |
struct apply { | |
typedef typename __meta_add<x, meta_integer<1> >::value value; | |
}; | |
}; | |
typedef typename n::template apply<__lambda_4, __dummy_arg>::value::template apply<meta_integer<0>, __dummy_arg>::value value; | |
}; | |
}; | |
typedef S::apply<S::apply<K::apply<S, __dummy_arg>::value, __dummy_arg>::value::apply<K, __dummy_arg>::value, __dummy_arg>::value Succ; | |
typedef K::apply<I, __dummy_arg>::value Zero; | |
typedef Succ::apply<Zero, __dummy_arg>::value One; | |
typedef Succ::apply<One, __dummy_arg>::value Two; | |
typedef Succ::apply<Two, __dummy_arg>::value Three; | |
typedef Succ::apply<Three, __dummy_arg>::value Four; | |
typedef Succ::apply<Four, __dummy_arg>::value Five; | |
typedef Succ::apply<Five, __dummy_arg>::value Six; | |
struct __lambda_4{ | |
template <typename n, typename _4> | |
struct apply { | |
struct __lambda_5{ | |
template <typename m, typename _5> | |
struct apply { | |
typedef typename m::template apply<Succ, __dummy_arg>::value::template apply<n, __dummy_arg>::value value; | |
}; | |
}; | |
typedef __lambda_5 value; | |
}; | |
}; | |
typedef __lambda_4 Plus; | |
struct __lambda_5{ | |
template <typename m, typename _5> | |
struct apply { | |
struct __lambda_6{ | |
template <typename n, typename _6> | |
struct apply { | |
struct __lambda_7{ | |
template <typename f, typename _7> | |
struct apply { | |
typedef typename m::template apply<typename n::template apply<f, __dummy_arg>::value, __dummy_arg>::value value; | |
}; | |
}; | |
typedef __lambda_7 value; | |
}; | |
}; | |
typedef __lambda_6 value; | |
}; | |
}; | |
typedef __lambda_5 Mult; | |
struct __lambda_6{ | |
template <typename m, typename _6> | |
struct apply { | |
struct __lambda_7{ | |
template <typename n, typename _7> | |
struct apply { | |
typedef typename n::template apply<m, __dummy_arg>::value value; | |
}; | |
}; | |
typedef __lambda_7 value; | |
}; | |
}; | |
typedef __lambda_6 Expo; | |
typedef SKI2Int::apply<Plus::apply<Two, __dummy_arg>::value::apply<Three, __dummy_arg>::value, __dummy_arg>::value Int_Two_Plus_Three; | |
typedef SKI2Int::apply<Plus::apply<Two, __dummy_arg>::value::apply<Four, __dummy_arg>::value, __dummy_arg>::value Int_Two_Plus_Four; | |
typedef SKI2Int::apply<Mult::apply<Two, __dummy_arg>::value::apply<Three, __dummy_arg>::value, __dummy_arg>::value Int_Two_Mult_Three; | |
typedef SKI2Int::apply<Mult::apply<Four, __dummy_arg>::value::apply<Three, __dummy_arg>::value, __dummy_arg>::value Int_Four_Mult_Three; | |
typedef SKI2Int::apply<Expo::apply<Two, __dummy_arg>::value::apply<Two, __dummy_arg>::value, __dummy_arg>::value Int_Two_Exp_Two; | |
typedef SKI2Int::apply<Expo::apply<Three, __dummy_arg>::value::apply<Two, __dummy_arg>::value, __dummy_arg>::value Int_Three_Exp_Two; | |
struct SKI2Bool { | |
template <typename x, typename _7> | |
struct apply { | |
typedef typename x::template apply<meta_integer<1>, __dummy_arg>::value::template apply<meta_integer<0>, __dummy_arg>::value value; | |
}; | |
}; | |
typedef SKI2Bool::apply<S::apply<K, __dummy_arg>::value::apply<S, __dummy_arg>::value::apply<K, __dummy_arg>::value, __dummy_arg>::value SKSK; | |
typedef SKI2Bool::apply<S::apply<K, __dummy_arg>::value::apply<I::apply<I::apply<S, __dummy_arg>::value, __dummy_arg>::value, __dummy_arg>::value::apply<K, __dummy_arg>::value, __dummy_arg>::value SKIISK; | |
int main(int argc, char *argv[]) | |
{ | |
std::cout << Int_Two_Plus_Three::value << std::endl; | |
std::cout << Int_Two_Plus_Four::value << std::endl; | |
std::cout << Int_Two_Mult_Three::value << std::endl; | |
std::cout << Int_Four_Mult_Three::value << std::endl; | |
std::cout << Int_Two_Exp_Two::value << std::endl; | |
std::cout << Int_Three_Exp_Two::value << std::endl; | |
std::cout << SKSK::value << std::endl; | |
std::cout << SKIISK::value << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment