oxedyne/fe2o3/fe2o3_austenite/tests/fixtures/eval/general/patterns.typ
1.2 KiB, 1 run
created by r1870400018:66106, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | // Patterns in parentheses: nested, spread, dictionary and placeholder, bound by `let`, `for` and parameters. |
| 2 | #let ((pa, pb)) = (1, 2) |
| 3 | #let (((pc, pd))) = (3, 4) |
| 4 | #let ((pe, pf), pg) = ((5, 6), 7) |
| 5 | #let (ph, (pi, pj), ..pk) = (8, (9, 10), 11, 12) |
| 6 | #let ((pl, ..pm)) = (13, 14, 15) |
| 7 | #let ((x: pn, ..po)) = (x: 16, y: 17, z: 18) |
| 8 | #let ((_, pp)) = (19, 20) |
| 9 | #metadata((pa, pb, pc, pd, pe, pf, pg, ph, pi, pj, pk, pl, pm, pn, po, pp)) <probe> |
| 10 | #metadata({ |
| 11 | let out = () |
| 12 | for ((k, ..r)) in (("a", 1, 2), ("b", 3)) { out.push((k, r)) } |
| 13 | for ((l, m)) in ((1, 2), (3, 4)) { out.push((l, m)) } |
| 14 | for ((k, v)) in (a: 1, b: 2) { out.push((k, v)) } |
| 15 | for (n, (o, p)) in ((1, (2, 3)), (4, (5, 6))) { out.push((n, o, p)) } |
| 16 | for ((n, (o, p))) in ((1, (2, 3)), (4, (5, 6))) { out.push((n, o, p)) } |
| 17 | for ((x: q, ..w)) in ((x: 1, y: 2), (x: 3, y: 4, z: 5)) { out.push((q, w)) } |
| 18 | out |
| 19 | }) <probe> |
| 20 | #let sum((x, y)) = x + y |
| 21 | #let prod(((x, y))) = x * y |
| 22 | #let diff = ((x, y)) => x - y |
| 23 | #let mix = (p, (x, y), ..rest) => p + x + y + rest.pos().len() |
| 24 | #metadata((sum((1, 2)), prod((3, 4)), diff((9, 4)), mix(1, (2, 3), 4, 5))) <probe> |
| 25 | #metadata({ |
| 26 | let a = 0 |
| 27 | let b = 0 |
| 28 | ((a, b) = (7, 8)) |
| 29 | (a, b) |
| 30 | }) <probe> |