-
-
Notifications
You must be signed in to change notification settings - Fork 373
/
Stringy.pm
65 lines (49 loc) · 2.48 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
61
62
63
64
65
my role Stringy { }
multi sub infix:<eqv>(Stringy:D $a, Stringy:D $b) {
$a.WHAT === $b.WHAT && ($a cmp $b) == 0
}
proto sub prefix:<~>($) is pure { * }
multi sub prefix:<~>(\a) { a.Stringy }
multi sub prefix:<~>(int $a) { nqp::p6box_s($a) }
multi sub prefix:<~>(num $a) { nqp::p6box_s($a) }
proto sub infix:<~>(|) is pure { * }
multi sub infix:<~>($x = '') { $x.Stringy }
multi sub infix:<~>(\a, \b) { a.Stringy ~ b.Stringy }
proto sub infix:<x>(Mu $?, Mu $?) { * }
multi sub infix:<x>() { fail "No zero-arg meaning for infix:<x>" }
multi sub infix:<x>($x) { $x.Stringy }
multi sub infix:<x>($s, $n) { $s.Stringy x ($n.Int // 0) }
proto sub infix:<leg>(Mu $?, Mu $?) is pure { * }
multi sub infix:<leg>(\a, \b) { a.Stringy cmp b.Stringy }
proto sub infix:<eq>(Mu $?, Mu $?) is pure { * }
multi sub infix:<eq>($x?) { Bool::True }
multi sub infix:<eq>(\a, \b) { a.Stringy eq b.Stringy }
proto sub infix:<ne>(Mu $?, Mu $?) is pure { * }
multi sub infix:<ne>($x?) { Bool::True }
multi sub infix:<ne>(Mu \a, Mu \b) { a !eq b }
multi sub infix:<ne>(Any \a, Any \b) { a.Stringy ne b.Stringy }
proto sub infix:<lt>(Mu $?, Mu $?) is pure { * }
multi sub infix:<lt>($x?) { Bool::True }
multi sub infix:<lt>(\a, \b) { a.Stringy lt b.Stringy }
proto sub infix:<le>(Mu $?, Mu $?) is pure { * }
multi sub infix:<le>($x?) { Bool::True }
multi sub infix:<le>(\a, \b) { a.Stringy le b.Stringy }
proto sub infix:<gt>(Mu $?, Mu $?) is pure { * }
multi sub infix:<gt>($x?) { Bool::True }
multi sub infix:<gt>(\a, \b) { a.Stringy gt b.Stringy }
proto sub infix:<ge>(Mu $?, Mu $?) is pure { * }
multi sub infix:<ge>($x?) { Bool::True }
multi sub infix:<ge>(\a, \b) { a.Stringy ge b.Stringy }
proto sub infix:<~|>(Mu $?, Mu $?) is pure { * }
multi sub infix:<~|>($x = '') { $x.Stringy }
multi sub infix:<~|>(\a, \b) { a.Stringy ~| b.Stringy }
proto sub infix:<~^>(Mu $?, Mu $?) is pure { * }
multi sub infix:<~^>($x = '') { $x.Stringy }
multi sub infix:<~^>(\a, \b) { a.Stringy ~^ b.Stringy }
proto sub infix:<~&>(Mu $?, Mu $?) is pure { * }
multi sub infix:<~&>() { fail "No zero-arg meaning for infix:<~&>" }
multi sub infix:<~&>($x) { $x.Stringy }
multi sub infix:<~&>(\a, \b) { a.Stringy ~& b.Stringy }
proto sub prefix:<~^>(Mu $) is pure { * }
multi sub prefix:<~^>(\a) { ~^ a.Stringy }
# vim: ft=perl6 expandtab sw=4