36 lines
601 B
Plaintext
36 lines
601 B
Plaintext
#lang honu
|
|
|
|
var => = 0
|
|
|
|
pattern match_pattern (){ [element:expression_list]} { [ $ element_each_result , $ ...]}
|
|
|
|
pattern match_clause (| =>){ | pattern:match_pattern => out:expression , }
|
|
|
|
macro mymatch(with){
|
|
thing:expression with
|
|
clause:match_clause ...
|
|
} {
|
|
syntax(
|
|
cond
|
|
$ clause_pattern == thing: clause_out, $ ...
|
|
else: -2
|
|
)
|
|
}
|
|
|
|
mymatch [1] with
|
|
| [1] => 5,
|
|
| [2] => 6,
|
|
|
|
mymatch [1, 2, 3] with
|
|
| [4] => 12,
|
|
| [1, 2] => 7,
|
|
| [1, 2, 3] => 8,
|
|
|
|
// mymatch [1] with | [2] => 5
|
|
|
|
mymatch [true, false] with
|
|
| [true] => 1,
|
|
| [false] => 2,
|
|
| [false, true] => 3,
|
|
| [true, false] => 4,
|