Last active 1738998538

Revision fb2524c001fcee90f2fa54aaea843b61f59ae4b8

generate-code.lua Raw 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 Raw 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