mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-26 08:38:47 +00:00
Pattern matching in X86
This commit is contained in:
parent
1f1ef2ce57
commit
57588f2605
18 changed files with 179 additions and 3 deletions
17
regression/test042.expr
Normal file
17
regression/test042.expr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
fun f (x) {
|
||||
case x of
|
||||
`nil -> write (0)
|
||||
| `cons (_, `nil) -> write (1)
|
||||
| `cons (_, `cons (_, `nil)) -> write (2)
|
||||
| `cons (_, `cons (_, `cons (_, `nil))) -> write (3)
|
||||
| _ -> write (4)
|
||||
esac
|
||||
}
|
||||
|
||||
x := read ();
|
||||
y := `nil;
|
||||
|
||||
for i := 0, i < 10, i := i + 1 do
|
||||
f (y);
|
||||
y := `cons (i, y)
|
||||
od
|
||||
Loading…
Add table
Add a link
Reference in a new issue