@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | public static function CAnd(): Closure |
18 | 18 | { |
19 | - return static fn (callable $l): Closure => static fn (callable $c): Closure => $l($c)(self::CFalse()); |
|
19 | + return static fn(callable $l): Closure => static fn(callable $c): Closure => $l($c)(self::CFalse()); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public static function CFalse(): Closure |
@@ -46,36 +46,36 @@ discard block |
||
46 | 46 | |
47 | 47 | public static function CXor(): Closure |
48 | 48 | { |
49 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => ($a($b(self::CFalse())(self::CTrue())))($b(self::CTrue())(self::CFalse())); |
|
49 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => ($a($b(self::CFalse())(self::CTrue())))($b(self::CTrue())(self::CFalse())); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public static function eq(): Closure |
53 | 53 | { |
54 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => self::CAnd()(self::lte()($a)($b))(self::lte()($b)($a)); |
|
54 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => self::CAnd()(self::lte()($a)($b))(self::lte()($b)($a)); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function gt(): Closure |
58 | 58 | { |
59 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => self::CNot()(self::lte()($a)($b)); |
|
59 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => self::CNot()(self::lte()($a)($b)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | public static function gte(): Closure |
63 | 63 | { |
64 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => self::isZero()(Numeral::minus()($b)($a)); |
|
64 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => self::isZero()(Numeral::minus()($b)($a)); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | public static function isZero(): Closure |
68 | 68 | { |
69 | - return static fn (callable $a): Closure => $a(static fn () => self::CFalse())(self::CTrue()); |
|
69 | + return static fn(callable $a): Closure => $a(static fn() => self::CFalse())(self::CTrue()); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | public static function lt(): Closure |
73 | 73 | { |
74 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => self::CNot()(self::gte()($a)($b)); |
|
74 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => self::CNot()(self::gte()($a)($b)); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | public static function lte(): Closure |
78 | 78 | { |
79 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => self::isZero()(Numeral::minus()($a)($b)); |
|
79 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => self::isZero()(Numeral::minus()($a)($b)); |
|
80 | 80 | } |
81 | 81 | } |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public static function eight(): Closure |
20 | 20 | { |
21 | - return static fn (callable $s): Closure => static fn ($z) => $s($s($s($s($s($s($s($s($z)))))))); |
|
21 | + return static fn(callable $s): Closure => static fn($z) => $s($s($s($s($s($s($s($s($z)))))))); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public static function exponentiation(): Closure |
25 | 25 | { |
26 | - return static fn (callable $f): Closure => static fn (callable $n): Closure => $n($f); |
|
26 | + return static fn(callable $f): Closure => static fn(callable $n): Closure => $n($f); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public static function five(): Closure |
33 | 33 | { |
34 | - return static fn (callable $s): Closure => static fn ($z) => $s($s($s($s($s($z))))); |
|
34 | + return static fn(callable $s): Closure => static fn($z) => $s($s($s($s($s($z))))); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -39,17 +39,17 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public static function four(): Closure |
41 | 41 | { |
42 | - return static fn (callable $s): Closure => static fn ($z) => $s($s($s($s($z)))); |
|
42 | + return static fn(callable $s): Closure => static fn($z) => $s($s($s($s($z)))); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public static function minus(): Closure |
46 | 46 | { |
47 | - return static fn (callable $x): Closure => static fn (callable $y): Closure => $y(self::pred())($x); |
|
47 | + return static fn(callable $x): Closure => static fn(callable $y): Closure => $y(self::pred())($x); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public static function multiply(): Closure |
51 | 51 | { |
52 | - return static fn (callable $x): Closure => static fn (callable $y): Closure => $x(self::plus()($y))(self::zero()); |
|
52 | + return static fn(callable $x): Closure => static fn(callable $y): Closure => $x(self::plus()($y))(self::zero()); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public static function nine(): Closure |
59 | 59 | { |
60 | - return static fn (callable $s): Closure => static fn ($z) => $s($s($s($s($s($s($s($s($s($z))))))))); |
|
60 | + return static fn(callable $s): Closure => static fn($z) => $s($s($s($s($s($s($s($s($s($z))))))))); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -65,17 +65,17 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public static function one(): Closure |
67 | 67 | { |
68 | - return static fn (callable $s): Closure => static fn ($z) => $s($z); |
|
68 | + return static fn(callable $s): Closure => static fn($z) => $s($z); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | public static function plus(): Closure |
72 | 72 | { |
73 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => static fn ($c): Closure => static fn ($d) => $b($c)($a($c)($d)); |
|
73 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => static fn($c): Closure => static fn($d) => $b($c)($a($c)($d)); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | public static function pred(): Closure |
77 | 77 | { |
78 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => static fn ($c) => $a(static fn ($d): Closure => static fn ($e) => $e($d($b)))(static fn () => $c)(static fn ($a) => $a); |
|
78 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => static fn($c) => $a(static fn($d): Closure => static fn($e) => $e($d($b)))(static fn() => $c)(static fn($a) => $a); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public static function seven(): Closure |
85 | 85 | { |
86 | - return static fn (callable $s): Closure => static fn ($z) => $s($s($s($s($s($s($s($z))))))); |
|
86 | + return static fn(callable $s): Closure => static fn($z) => $s($s($s($s($s($s($s($z))))))); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function six(): Closure |
93 | 93 | { |
94 | - return static fn (callable $s): Closure => static fn ($z) => $s($s($s($s($s($s($z)))))); |
|
94 | + return static fn(callable $s): Closure => static fn($z) => $s($s($s($s($s($s($z)))))); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | public static function succ(): Closure |
98 | 98 | { |
99 | - return static fn (callable $n): Closure => static fn (callable $s): Closure => static fn ($z) => $s($n($s)($z)); |
|
99 | + return static fn(callable $n): Closure => static fn(callable $s): Closure => static fn($z) => $s($n($s)($z)); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,19 +104,18 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public static function three(): Closure |
106 | 106 | { |
107 | - return static fn (callable $s): Closure => static fn ($z) => $s($s($s($z))); |
|
107 | + return static fn(callable $s): Closure => static fn($z) => $s($s($s($z))); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | public static function toInt(callable $numeral) |
111 | 111 | { |
112 | - return $numeral(static fn (int $n): int => $n + 1)(0); |
|
112 | + return $numeral(static fn(int $n): int => $n + 1)(0); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | public static function toNumeral(int $n): Closure |
116 | 116 | { |
117 | 117 | return 0 === $n - 1 ? |
118 | - Numeral::one() : |
|
119 | - Numeral::plus()(Numeral::one())(Numeral::toNumeral($n - 1)); |
|
118 | + Numeral::one() : Numeral::plus()(Numeral::one())(Numeral::toNumeral($n - 1)); |
|
120 | 119 | } |
121 | 120 | |
122 | 121 | /** |
@@ -124,7 +123,7 @@ discard block |
||
124 | 123 | */ |
125 | 124 | public static function two(): Closure |
126 | 125 | { |
127 | - return static fn (callable $s) => static fn ($z) => $s($s($z)); |
|
126 | + return static fn(callable $s) => static fn($z) => $s($s($z)); |
|
128 | 127 | } |
129 | 128 | |
130 | 129 | /** |
@@ -132,6 +131,6 @@ discard block |
||
132 | 131 | */ |
133 | 132 | public static function zero(): Closure |
134 | 133 | { |
135 | - return static fn (callable $s) => static fn ($z) => $z; |
|
134 | + return static fn(callable $s) => static fn($z) => $z; |
|
136 | 135 | } |
137 | 136 | } |
@@ -15,16 +15,16 @@ |
||
15 | 15 | { |
16 | 16 | public static function first(): Closure |
17 | 17 | { |
18 | - return static fn (callable $a) => $a(static fn ($b): Closure => static fn () => $b); |
|
18 | + return static fn(callable $a) => $a(static fn($b): Closure => static fn() => $b); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function of(): Closure |
22 | 22 | { |
23 | - return static fn ($a): Closure => static fn ($b): Closure => static fn ($c) => $c($a)($b); |
|
23 | + return static fn($a): Closure => static fn($b): Closure => static fn($c) => $c($a)($b); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public static function second(): Closure |
27 | 27 | { |
28 | - return static fn (callable $a) => $a(static fn (): Closure => static fn ($b) => $b); |
|
28 | + return static fn(callable $a) => $a(static fn(): Closure => static fn($b) => $b); |
|
29 | 29 | } |
30 | 30 | } |
@@ -16,31 +16,31 @@ discard block |
||
16 | 16 | { |
17 | 17 | public static function concat(): Closure |
18 | 18 | { |
19 | - return static fn (callable $xs): Closure => static fn (callable $ys): Closure => self::foldr()(self::cons())($ys)($xs); |
|
19 | + return static fn(callable $xs): Closure => static fn(callable $ys): Closure => self::foldr()(self::cons())($ys)($xs); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public static function cons() |
23 | 23 | { |
24 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => Pair::of()(Boolean::CFalse())(Pair::of()($a)($b)); |
|
24 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => Pair::of()(Boolean::CFalse())(Pair::of()($a)($b)); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public static function foldl() |
28 | 28 | { |
29 | - return static fn (callable $f): Closure => static fn ($a): Closure => static fn (callable $xs) => self::foldr()( |
|
30 | - static fn (callable $x): Closure => static fn (callable $g): Closure => static fn ($y) => $g($f($y)($x)) |
|
31 | - )(static fn ($x) => $x)($xs)($a); |
|
29 | + return static fn(callable $f): Closure => static fn($a): Closure => static fn(callable $xs) => self::foldr()( |
|
30 | + static fn(callable $x): Closure => static fn(callable $g): Closure => static fn($y) => $g($f($y)($x)) |
|
31 | + )(static fn($x) => $x)($xs)($a); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | public static function foldr() |
35 | 35 | { |
36 | 36 | return Combinators::Y()( |
37 | - static fn (callable $r): Closure => static fn (callable $f): Closure => static fn ($a): Closure => static fn (callable $xs) => Boolean::CIf()(self::isNil()($xs))(static fn () => $a)(static fn () => $f(self::head()($xs))($r($f)($a)(self::tail()($xs))))() |
|
37 | + static fn(callable $r): Closure => static fn(callable $f): Closure => static fn($a): Closure => static fn(callable $xs) => Boolean::CIf()(self::isNil()($xs))(static fn() => $a)(static fn() => $f(self::head()($xs))($r($f)($a)(self::tail()($xs))))() |
|
38 | 38 | ); |
39 | 39 | } |
40 | 40 | |
41 | 41 | public static function head() |
42 | 42 | { |
43 | - return static fn (callable $a): Closure => Pair::first()(Pair::second()($a)); |
|
43 | + return static fn(callable $a): Closure => Pair::first()(Pair::second()($a)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | public static function isNil() |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | public static function length() |
52 | 52 | { |
53 | - return self::foldl()(static fn (callable $a): Closure => static fn (callable $b): Closure => Numeral::succ()($a))(Numeral::zero()); |
|
53 | + return self::foldl()(static fn(callable $a): Closure => static fn(callable $b): Closure => Numeral::succ()($a))(Numeral::zero()); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public static function nil() |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | |
61 | 61 | public static function range() |
62 | 62 | { |
63 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => Numeral::minus()(Numeral::succ()($b))($a)(static fn (callable $c): Closure => CList::cons()(Numeral::minus()($b)(CList::length()($c)))($c))(CList::nil()); |
|
63 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => Numeral::minus()(Numeral::succ()($b))($a)(static fn(callable $c): Closure => CList::cons()(Numeral::minus()($b)(CList::length()($c)))($c))(CList::nil()); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | public static function repeat() |
67 | 67 | { |
68 | - return static fn (callable $a): Closure => static fn (callable $b): Closure => $b( |
|
69 | - static fn ($c): Closure => CList::cons()($a)($c) |
|
68 | + return static fn(callable $a): Closure => static fn(callable $b): Closure => $b( |
|
69 | + static fn($c): Closure => CList::cons()($a)($c) |
|
70 | 70 | )(CList::nil()); |
71 | 71 | } |
72 | 72 | |
@@ -77,6 +77,6 @@ discard block |
||
77 | 77 | |
78 | 78 | public static function tail(): Closure |
79 | 79 | { |
80 | - return static fn (callable $a): Closure => Pair::second()(Pair::second()($a)); |
|
80 | + return static fn(callable $a): Closure => Pair::second()(Pair::second()($a)); |
|
81 | 81 | } |
82 | 82 | } |