Zuletzt aktiv 1738998538

Änderung e46b4b0a61d7aa9dabcfa0a940a3d1b33b51936c

generate-code.lua Orginalformat Playground
1
2function run_rules(state)
3 if state["flour"] >= 1 and state["sugar"] >= 1 and state["apples"] >= 1 then
4 emit(state, "apple cake")
5 return run_rules(state)
6 elseif state["apples"] >= 1 and state["oranges"] >= 1 and state["cherries"] >= 1 then
7 emit(state, "fruit salad")
8 return run_rules(state)
9 elseif state["fruit salad"] >= 1 and state["apple cake"] >= 1 then
10 emit(state, "fruit cake")
11 return run_rules(state)
12 else
13 end
14end
15
16tally(state, "sugar")
17tally(state, "oranges")
18tally(state, "apples")
19tally(state, "cherries")
20tally(state, "flour")
21tally(state, "apples")
22run_rules(state)
linear-multiset-catlang.txt Orginalformat Playground
1function (run rules) [flour sugar apples]
2 (> (apple cake)) (run rules)
3end
4
5function (run rules) [apples oranges cherries]
6 (> (fruit salad)) (run rules)
7end
8
9function (run rules) [(fruit salad) (apple cake)]
10 (> (fruit cake)) (run rules)
11end
12
13function (run rules) []
14end
15
16(> sugar) (> oranges)
17(> apples) (> cherries)
18(> flour) (> apples)
19(run rules)
20
something.lua Orginalformat Playground
1local operation_stack = { ... }
2local fact_pool = { ... }
3local operations = { ... }
4
5while #ops > 0 do
6 local op = pop(operation_stack)
7 operations[op](operation_stack, fact_pool)
8end