33 typedef typename compositor_t::function function_t;
37 symbol_table_t symbol_table;
38 symbol_table.add_package(io_package);
39 symbol_table.add_function(
"print_coeff",
42 printf(
"%6d",
static_cast<unsigned int>(t));
46 compositor_t compositor(symbol_table);
49 function_t(
"n_choose_k")
57 " default : n_choose_k(n - 1, k - 1) + "
58 " n_choose_k(n - 1, k ) ; "
62 const std::string pascals_triangle_program =
63 " const var rows := 20; "
65 " for (var n := 0; n < rows; n += 1) "
67 " for (var s := 0; s <= (rows - n) - 2; s += 1) "
72 " for (var k := 0; k <= n; k += 1) "
74 " print_coeff(n_choose_k(n,k)); "
80 expression_t expression;
81 expression.register_symbol_table(symbol_table);
84 parser.compile(pascals_triangle_program,expression);