32 typedef typename compositor_t::function function_t;
39 symbol_table.add_variable(
"x",
x);
41 compositor_t compositor(symbol_table);
49 " if (0 == (x % y),false, " 50 " is_prime_impl1(x,y - 1))) ",
57 " if (frac(x) != 0, false, " 58 " if (x <= 0, false, " 59 " is_prime_impl1(x,min(x - 1,trunc(sqrt(x)) + 1)))) ",
69 " case y == 1 : true; " 70 " case (x % y) == 0 : false; " 71 " default : is_prime_impl2(x,y - 1); " 81 " case x <= 0 : false; " 82 " case frac(x) != 0 : false; " 83 " default : is_prime_impl2(x,min(x - 1,trunc(sqrt(x)) + 1)); " 96 " case y == 1 : ~(y := 0,true); " 97 " case (x % y) == 0 : ~(y := 0,false); " 98 " default : y := y - 1; " 109 " case x <= 0 : false; " 110 " case frac(x) != 0 : false; " 111 " default : is_prime_impl3(x,min(x - 1,trunc(sqrt(x)) + 1)); " 123 expression2.register_symbol_table(symbol_table);
124 expression3.register_symbol_table(symbol_table);
128 parser.compile(expression_str1,expression1);
129 parser.compile(expression_str2,expression2);
130 parser.compile(expression_str3,expression3);
132 for (std::size_t i = 0; i < 100; ++i)
134 x =
static_cast<T
>(i);
136 T result1 = expression1.value();
137 T result2 = expression2.value();
138 T result3 = expression3.value();
140 printf(
"%03d Result1: %c Result2: %c Result3: %c\n",
141 static_cast<unsigned int>(i),
142 (result1 == T(1)) ?
'T' :
'F',
143 (result2 == T(1)) ?
'T' :
'F',
144 (result3 == T(1)) ?
'T' :
'F');