@@ -3,8 +3,8 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('unique', function (array $list): array { |
|
7 | - $reducer = function ($carry, $item) { |
|
6 | +P::macro('unique', function(array $list): array { |
|
7 | + $reducer = function($carry, $item) { |
|
8 | 8 | return in_array($item, $carry, true) ? $carry : P::append($item, $carry); |
9 | 9 | }; |
10 | 10 |
@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('sortBy', function (callable $mapper, array $list): array { |
|
6 | +P::macro('sortBy', function(callable $mapper, array $list): array { |
|
7 | 7 | $column = array_map($mapper, $list); |
8 | 8 | array_multisort($column, \SORT_REGULAR, $list); |
9 | 9 |
@@ -3,6 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('tail', function ($collection) { |
|
6 | +P::macro('tail', function($collection) { |
|
7 | 7 | return P::slice(1, P::length($collection), $collection); |
8 | 8 | }); |
@@ -3,9 +3,9 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('concat', function ($a, $b) { |
|
6 | +P::macro('concat', function($a, $b) { |
|
7 | 7 | $getTypes = P::unapply(P::map('\\gettype')); |
8 | - $matchesType = function (string $type) use ($getTypes) { |
|
8 | + $matchesType = function(string $type) use ($getTypes) { |
|
9 | 9 | return P::compose([P::equals([$type, $type]), $getTypes]); |
10 | 10 | }; |
11 | 11 |
@@ -3,8 +3,8 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('append', function ($value, $collection) { |
|
7 | - $pushToArray = function (array $copy) use ($value) { |
|
6 | +P::macro('append', function($value, $collection) { |
|
7 | + $pushToArray = function(array $copy) use ($value) { |
|
8 | 8 | array_push($copy, $value); |
9 | 9 | return $copy; |
10 | 10 | }; |
@@ -3,6 +3,6 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('filter', function (callable $predicate, array $list): array { |
|
6 | +P::macro('filter', function(callable $predicate, array $list): array { |
|
7 | 7 | return array_values(array_filter($list, $predicate)); |
8 | 8 | }); |
@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('length', function ($collection): int { |
|
6 | +P::macro('length', function($collection): int { |
|
7 | 7 | return P::apply( |
8 | 8 | P::cond([ |
9 | 9 | ['\\is_countable', '\\count'], |
@@ -3,10 +3,10 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('fromPairs', function (array $pairs): array { |
|
6 | +P::macro('fromPairs', function(array $pairs): array { |
|
7 | 7 | return array_reduce( |
8 | 8 | $pairs, |
9 | - function ($carry, $item) { |
|
9 | + function($carry, $item) { |
|
10 | 10 | list ($key, $value) = $item; |
11 | 11 | |
12 | 12 | return array_merge($carry, [$key => $value]); |
@@ -3,10 +3,10 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('collapse', function (array $list): array { |
|
6 | +P::macro('collapse', function(array $list): array { |
|
7 | 7 | return array_reduce( |
8 | 8 | $list, |
9 | - function ($carry, $item) { |
|
9 | + function($carry, $item) { |
|
10 | 10 | return is_array($item) |
11 | 11 | ? array_merge($carry, $item) |
12 | 12 | : P::append($item, $carry); |