PHP code example of cognesy / instructor-stream
1. Go to this page and download the library: Download cognesy/instructor-stream 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/ */
cognesy / instructor-stream example snippets
use Cognesy\Stream\Transformation;
use Cognesy\Stream\Transform\Filter\Transducers\Filter;
use Cognesy\Stream\Transform\Limit\Transducers\TakeN;
use Cognesy\Stream\Transform\Map\Transducers\Map;
$result = Transformation::define(
new Map(fn($x) => $x * 2),
new Filter(fn($x) => $x > 5),
new TakeN(3),
)->executeOn([1, 2, 3, 4, 5, 6]);