codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include<stdio.h> #define PP_INC_0 1 #define PP_INC_1 2 #define PP_INC_2 3 #define PP_INC_3 3 #define PP_INC(n) PP_INC_I(n) #define PP_INC_I(n) PP_INC_ ## n #define PP_DEC_0 0 #define PP_DEC_1 0 #define PP_DEC_2 1 #define PP_DEC_3 2 #define PP_DEC(n) PP_DEC_I(n) #define PP_DEC_I(n) PP_DEC_ ## n #define PP_IF_0(t, f) f #define PP_IF_1(t, f) t #define PP_IF(c, t, f) PP_IF_I(c, t, f) #define PP_IF_I(c, t, f) PP_IF_ ## c (t, f) #define PP_BOOL_0 0 #define PP_BOOL_1 1 #define PP_BOOL_2 1 #define PP_BOOL_3 1 #define PP_BOOL(n) PP_BOOL_I(n) #define PP_BOOL_I(n) PP_BOOL_ ## n #define PP_TUPLE_ELEM_1_0(a) a #define PP_TUPLE_ELEM_2_0(a, b) a #define PP_TUPLE_ELEM_2_1(a, b) b #define PP_TUPLE_ELEM_3_0(a, b, c) a #define PP_TUPLE_ELEM_3_1(a, b, c) b #define PP_TUPLE_ELEM_3_2(a, b, c) c #define PP_TUPLE_ELEM(n, i, tup) PP_TUPLE_ELEM_I(n, i, tup) #define PP_TUPLE_ELEM_I(n, i, tup) PP_TUPLE_ELEM_ ## n ## _ ## i tup #define PP_ADD(m, n) PP_TUPLE_ELEM(2, 1, PP_ADD_I(PP_ADD_I(PP_ADD_I(PP_ADD_I(PP_ADD_I(PP_ADD_I(PP_ADD_I(PP_ADD_I((m, n)))))))))) #define PP_ADD_I(tup) PP_ADD_II tup #define PP_ADD_II(m, n) PP_IF(PP_BOOL(m), (PP_DEC(m), PP_INC(n)), (m, n)) #define PP_TO_STR(a) PP_TO_STR_I(a) #define PP_TO_STR_I(a) PP_TO_STR_II(a) #define PP_TO_STR_II(a) #a main() { printf("%s", PP_TO_STR(PP_ADD(1, 2))); return 0; }
Private
[
?
]
Run code
Submit