|
@@ 338-355 (lines=18) @@
|
| 335 |
|
* @param array|string|\Iterator $iterable Additional $iterable parameters may follow |
| 336 |
|
* @return MapIterator |
| 337 |
|
*/ |
| 338 |
|
function map($strategy, $iterable) |
| 339 |
|
{ |
| 340 |
|
// note, once we stop supporting php 5.5, we can rewrite the code below |
| 341 |
|
// to the map(...$iterables) structure. |
| 342 |
|
// http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list |
| 343 |
|
|
| 344 |
|
if (func_num_args() > 2) { |
| 345 |
|
$iterables = array_slice(func_get_args(), 2); |
| 346 |
|
} else { |
| 347 |
|
$iterables = []; |
| 348 |
|
} |
| 349 |
|
|
| 350 |
|
if (!($iterable instanceof ChainInterface)) { |
| 351 |
|
$iterable = iterable($iterable); |
| 352 |
|
} |
| 353 |
|
|
| 354 |
|
return call_user_func_array([$iterable, 'map'], array_merge([$strategy], $iterables)); |
| 355 |
|
} |
| 356 |
|
|
| 357 |
|
/** |
| 358 |
|
* Select values from the iterator by applying a function to each of the iterator values, i.e., mapping it to the |
|
@@ 613-630 (lines=18) @@
|
| 610 |
|
* @param array|string|\Iterator $iterable Additional $iterable parameters may follow |
| 611 |
|
* @return ZipIterator |
| 612 |
|
*/ |
| 613 |
|
function zip($iterable) |
| 614 |
|
{ |
| 615 |
|
// note, once we stop supporting php 5.5, we can rewrite the code below |
| 616 |
|
// to the zip(...$iterables) structure. |
| 617 |
|
// http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list |
| 618 |
|
|
| 619 |
|
if (func_num_args() > 1) { |
| 620 |
|
$iterables = array_slice(func_get_args(), 1); |
| 621 |
|
} else { |
| 622 |
|
$iterables = []; |
| 623 |
|
} |
| 624 |
|
|
| 625 |
|
if (!($iterable instanceof ZipInterface)) { |
| 626 |
|
$iterable = iterable($iterable); |
| 627 |
|
} |
| 628 |
|
|
| 629 |
|
return call_user_func_array([$iterable, 'zip'], $iterables); |
| 630 |
|
} |
| 631 |
|
|
| 632 |
|
/** |
| 633 |
|
* Returns an iterable with all the elements from $iterable reversed |