Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_austenite/tests/fixtures/eval/foundation/higher_order.txt

2.2 KiB, 1 run

created by r1870400018:63838, 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// methods that take a function, and the operator-backed ones, through the evaluator proper.
2(1, 2, 3).map(x => x * 2)
3(1, 2, 3, 4).filter(calc.even)
4(1, 2, 3).find(x => x > 1)
5(1, 2, 3).find(x => x > 5)
6(1, 2, 3).position(x => x == 3)
7(1, 2, 3).any(x => x > 2)
8(1, 2, 3).all(x => x > 0)
9(1, 2, 3).fold(0, (a, b) => a + b)
10(1, 2, 3).reduce((a, b) => a * b)
11().reduce((a, b) => a * b)
12(1, 2, 3).sum()
13().sum(default: 0pt)
14(1pt, 2pt).sum()
15("a", "b").sum()
16(2, 3, 4).product()
17(1.5, 2).product()
18("a", "b", "c").join(", ")
19("a", "b", "c").join(", ", last: " and ")
20((1,), (2,)).join()
21([a], [b]).join([ ])
22(3, 1, 2).sorted()
23("b", "A", "a").sorted()
24(3, 1, 2).sorted(key: x => -x)
25((1, "b"), (1, "a"), (0, "c")).sorted(key: p => p.at(0))
26(3, 1, 2).sorted(by: (a, b) => a > b)
27(1, 1, 2, 1).dedup()
28(1, 2, 3, 4).dedup(key: x => calc.rem(x, 2))
29((1, 2), (3, 4)).map(((a, b)) => a + b)
30(a: 1, b: 2).pairs().map(((k, v)) => k + str(v))
31(a: 1, b: 2, c: 3).filter(v => v > 1)
32(a: 1, b: 2).map(v => v * 2)
33"a,b".split(",").map(s => s + s)
34"hello world".replace(regex("o"), m => m.text + "!")
35"a1b22".replace(regex("\\d+"), m => str(int(m.text) * 2))
36"abc".replace("b", m => m.text + m.text)
37calc.max(1, 2.5, -3)
38calc.min("b", "a")
39calc.max(1pt, 3pt)
40(1, 2, 3).map(str).join()
41range(5).map(i => i * i).filter(i => calc.odd(i))
42{let a = (1, 2, 3); let r = a.push(4); (r, a)}
43{let a = (1, 2, 3); let r = a.pop(); (r, a)}
44{let a = (1, 2, 3); let r = a.insert(1, 9); (r, a)}
45{let a = (1, 2, 3); let r = a.insert(3, 9); (r, a)}
46{let a = (1, 2, 3); let r = a.insert(-1, 9); (r, a)}
47{let a = (1, 2, 3); let r = a.remove(0); (r, a)}
48{let a = (1, 2, 3); let r = a.remove(-1); (r, a)}
49{let a = (1, 2, 3); let r = a.remove(5, default: 9); (r, a)}
50{let a = (a: 1); let r = a.insert("b", 2); (r, a)}
51{let a = (a: 1, b: 2); let r = a.insert("a", 3); (r, a)}
52{let a = (a: 1, b: 2); let r = a.remove("a"); (r, a)}
53{let a = (a: 1); let r = a.remove("z", default: 0); (r, a)}
54!(1, 2).map(x => x.foo)
55!(1, "a").sum()
56!((1, "a"), (1, 2)).sorted()
57!(1, "a").sorted()
58!(1, 2).fold(0)
59!().pop()
60!(1,).map((a, b) => a)
61"\\d".len()
62"a1b22".matches(regex("\\d+")).len()
63"a1b22".replace(regex("[0-9]+"), m => str(int(m.text) * 2))
64(1, 2, 3).map(str)
65(a: 1).map(repr)