@@ -3,6 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Baethon\Phln\Phln as P; |
| 5 | 5 | |
| 6 | -P::macro('pluck', function ($key, array $list): array { |
|
| 6 | +P::macro('pluck', function($key, array $list): array { |
|
| 7 | 7 | return P::map(P::prop($key), $list); |
| 8 | 8 | }); |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Baethon\Phln\Phln as P; |
| 5 | 5 | |
| 6 | -P::macro('head', function ($collection) { |
|
| 6 | +P::macro('head', function($collection) { |
|
| 7 | 7 | $sliceFirst = P::slice(0, 1); |
| 8 | 8 | $moreThanZero = P::compose([P::lte(1), P::ref('length')]); |
| 9 | 9 | $headOfArray = P::cond([ |
@@ -3,6 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Baethon\Phln\Phln as P; |
| 5 | 5 | |
| 6 | -P::macro('reduce', function (callable $reducer, $initialValue, array $list) { |
|
| 6 | +P::macro('reduce', function(callable $reducer, $initialValue, array $list) { |
|
| 7 | 7 | return array_reduce($list, $reducer, $initialValue); |
| 8 | 8 | }); |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Baethon\Phln\Phln as P; |
| 5 | 5 | |
| 6 | -P::macro('sort', function (callable $comparator, array $list): array { |
|
| 6 | +P::macro('sort', function(callable $comparator, array $list): array { |
|
| 7 | 7 | usort($list, $comparator); |
| 8 | 8 | return $list; |
| 9 | 9 | }); |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Baethon\Phln\Phln as P; |
| 5 | 5 | |
| 6 | -P::macro('prepend', function ($value, $collection) { |
|
| 7 | - $arrayPrepend = function (array $copy) use ($value) { |
|
| 6 | +P::macro('prepend', function($value, $collection) { |
|
| 7 | + $arrayPrepend = function(array $copy) use ($value) { |
|
| 8 | 8 | array_unshift($copy, $value); |
| 9 | 9 | return $copy; |
| 10 | 10 | }; |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Baethon\Phln\Phln as P; |
| 5 | 5 | |
| 6 | -P::macro('last', function ($list) { |
|
| 6 | +P::macro('last', function($list) { |
|
| 7 | 7 | $lastElement = P::slice(-1, 1); |
| 8 | 8 | $lastOfArray = P::pipe([ |
| 9 | 9 | $lastElement, |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Baethon\Phln\Phln as P; |
| 5 | 5 | |
| 6 | -P::macro('all', function (callable $predicate, array $list): bool { |
|
| 6 | +P::macro('all', function(callable $predicate, array $list): bool { |
|
| 7 | 7 | foreach ($list as $value) { |
| 8 | 8 | if (false === $predicate($value)) { |
| 9 | 9 | return false; |
@@ -3,6 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Baethon\Phln\Phln as P; |
| 5 | 5 | |
| 6 | -P::macro('map', function (callable $fn = null, array $list = []) { |
|
| 6 | +P::macro('map', function(callable $fn = null, array $list = []) { |
|
| 7 | 7 | return array_map($fn, $list); |
| 8 | 8 | }); |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Baethon\Phln\Phln as P; |
| 5 | 5 | |
| 6 | -P::macro('reverse', function ($collection) { |
|
| 6 | +P::macro('reverse', function($collection) { |
|
| 7 | 7 | return P::apply( |
| 8 | 8 | P::typeCond([ |
| 9 | 9 | ['array', '\\array_reverse'], |