|
@@ 363-380 (lines=18) @@
|
| 360 |
|
* @return MapIterator |
| 361 |
|
* @deprecated Use iterable($iterable)->map($strategy, [$iterable2, ...]), will be removed in version 3.0 |
| 362 |
|
*/ |
| 363 |
|
function map($strategy, $iterable) |
| 364 |
|
{ |
| 365 |
|
// note, once we stop supporting php 5.5, we can rewrite the code below |
| 366 |
|
// to the map(...$iterables) structure. |
| 367 |
|
// http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list |
| 368 |
|
|
| 369 |
|
if (func_num_args() > 2) { |
| 370 |
|
$iterables = array_slice(func_get_args(), 2); |
| 371 |
|
} else { |
| 372 |
|
$iterables = []; |
| 373 |
|
} |
| 374 |
|
|
| 375 |
|
if (!($iterable instanceof ChainInterface)) { |
| 376 |
|
$iterable = iterable($iterable); |
| 377 |
|
} |
| 378 |
|
|
| 379 |
|
return call_user_func_array([$iterable, 'map'], array_merge([$strategy], $iterables)); |
| 380 |
|
} |
| 381 |
|
|
| 382 |
|
/** |
| 383 |
|
* Select values from the iterator by applying a function to each of the iterator values, i.e., mapping it to the |
|
@@ 644-661 (lines=18) @@
|
| 641 |
|
* @return ZipIterator |
| 642 |
|
* @deprecated Use iterable($iterable)->zip($iterable2, [$iterable3, ...]), will be removed in version 3.0 |
| 643 |
|
*/ |
| 644 |
|
function zip($iterable) |
| 645 |
|
{ |
| 646 |
|
// note, once we stop supporting php 5.5, we can rewrite the code below |
| 647 |
|
// to the zip(...$iterables) structure. |
| 648 |
|
// http://php.net/manual/en/functions.arguments.php#functions.variable-arg-list |
| 649 |
|
|
| 650 |
|
if (func_num_args() > 1) { |
| 651 |
|
$iterables = array_slice(func_get_args(), 1); |
| 652 |
|
} else { |
| 653 |
|
$iterables = []; |
| 654 |
|
} |
| 655 |
|
|
| 656 |
|
if (!($iterable instanceof ZipInterface)) { |
| 657 |
|
$iterable = iterable($iterable); |
| 658 |
|
} |
| 659 |
|
|
| 660 |
|
return call_user_func_array([$iterable, 'zip'], $iterables); |
| 661 |
|
} |
| 662 |
|
|
| 663 |
|
/** |
| 664 |
|
* Returns an iterable with all the elements from $iterable reversed |