-
-
Notifications
You must be signed in to change notification settings - Fork 373
/
Stringy.pm
61 lines (45 loc) · 2.02 KB
/
Stringy.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
my role Stringy { }
multi sub infix:<eqv>(Stringy:D $a, Stringy:D $b) {
$a.WHAT === $b.WHAT && ($a cmp $b) == 0
}
proto prefix:<~>(|) { * }
multi prefix:<~>(\a) { a.Stringy }
proto infix:<~>(|) { * }
multi infix:<~>($x = '') { $x.Stringy }
multi infix:<~>(\a, \b) { a.Stringy ~ b.Stringy }
proto infix:<x>(|) { * }
multi infix:<x>() { fail "No zero-arg meaning for infix:<x>" }
multi infix:<x>($x) { $x.Stringy }
multi infix:<x>($s, $n) { $s.Stringy x ($n.Int // 0) }
proto infix:<leg>(|) { * }
multi infix:<leg>(\a, \b) { a.Stringy cmp b.Stringy }
proto infix:<eq>(|) { * }
multi infix:<eq>($x?) { Bool::True }
multi infix:<eq>(\a, \b) { a.Stringy eq b.Stringy }
proto infix:<ne>(|) { * }
multi infix:<ne>($x?) { Bool::True }
multi infix:<ne>(Mu \a, Mu \b) { a !eq b }
proto infix:<lt>(|) { * }
multi infix:<lt>($x?) { Bool::True }
multi infix:<lt>(\a, \b) { a.Stringy lt b.Stringy }
proto infix:<le>(|) { * }
multi infix:<le>($x?) { Bool::True }
multi infix:<le>(\a, \b) { a.Stringy le b.Stringy }
proto infix:<gt>(|) { * }
multi infix:<gt>($x?) { Bool::True }
multi infix:<gt>(\a, \b) { a.Stringy gt b.Stringy }
proto infix:<ge>(|) { * }
multi infix:<ge>($x?) { Bool::True }
multi infix:<ge>(\a, \b) { a.Stringy ge b.Stringy }
proto infix:<~|>(|) { * }
multi infix:<~|>($x = '') { $x.Stringy }
multi infix:<~|>(\a, \b) { a.Stringy ~| b.Stringy }
proto infix:<~^>(|) { * }
multi infix:<~^>($x = '') { $x.Stringy }
multi infix:<~^>(\a, \b) { a.Stringy ~^ b.Stringy }
proto infix:<~&>(|) { * }
multi infix:<~&>() { fail "No zero-arg meaning for infix:<~&>" }
multi infix:<~&>($x) { $x.Stringy }
multi infix:<~&>(\a, \b) { a.Stringy ~& b.Stringy }
proto prefix:<~^>(|) { * }
multi prefix:<~^>(\a) { ~^ a.Stringy }