1. Go to this page and download the library: Download yuyat/piper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yuyat / piper example snippets
use yuyat\Piper;
use function iter\fn\operator;
use function iter\range;
$result = Piper::from(range(1, 10))
->pipe('iter\map', [operator('*', 2)])
->pipe(function ($iter) { return reduce(operator('+'), $iter, 0); })
->get();
echo $result, PHP_EOL;
// => 110
use yuyat\Piper;
use function iter\fn\operator;
use function iter\range;
use function iter\map;
use function iter\reduce;
class IterPiper extends Piper
{
public function map($fn)
{
return new static(map($fn, $this->get()));
}
public function reduce($fn, $initial = null)
{
return new static(reduce($fn, $this->get(), $initial));
}
}
$result = IterPiper::from(range(1, 10))
->map(operator('*', 2))
->reduce(operator('+'), 0)
->get();
echo $result, PHP_EOL;
// => 110
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.