mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-29 10:08:47 +00:00
Pattern matching in X86
This commit is contained in:
parent
9f8391607d
commit
bbe403de26
18 changed files with 179 additions and 3 deletions
23
regression/test038.expr
Normal file
23
regression/test038.expr
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
fun append (x, y) {
|
||||
case x of
|
||||
`nil -> return y
|
||||
| `cons (h, t) -> return `cons (h, append (t, y))
|
||||
esac
|
||||
}
|
||||
|
||||
fun printList (x) {
|
||||
case x of
|
||||
`nil -> skip
|
||||
| `cons (h, t) -> write (h); printList (t)
|
||||
esac
|
||||
}
|
||||
|
||||
n := read ();
|
||||
|
||||
x := `cons (1, `cons (2, `nil));
|
||||
y := `cons (3, `cons (4, `nil));
|
||||
|
||||
printList (x);
|
||||
printList (y);
|
||||
printList (append (x, y));
|
||||
printList (append (y, x))
|
||||
Loading…
Add table
Add a link
Reference in a new issue