mcenv / box

A dependently-typed programming language for Minecraft
https://mcenv.github.io/book-box/
MIT License
8 stars 0 forks source link

Optimize pattern matching #474

Open intsuc opened 1 year ago

intsuc commented 1 year ago

Examples

if x [
  {a: 0, b: 0} -> 1,
  {a: 0, b: 1} -> 2,
  {a: 1}       -> 3,
]
#> linear
execute if data storage mcx: {scrutinee: {a: 0, b: 0}} run 1
execute if data storage mcx: {scrutinee: {a: 0, b: 1}} run 2
execute if data storage mcx: {scrutinee: {a: 1}} run 3
#> decision tree
execute if data storage mcx: {scrutinee: {a: 0}} run
  execute if data storage mcx: {scrutinee: {b: 0}} run 1
  execute if data storage mcx: {scrutinee: {b: 1}} run 2
execute if data storage mcx: {scrutinee: {a: 1}} run 3
#> backtracking automaton
# todo