PHP code example of fiisoft / jackdaw-stream

1. Go to this page and download the library: Download fiisoft/jackdaw-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/ */

    

fiisoft / jackdaw-stream example snippets


Stream::from(Producers::sequentialInt())
    ->mapKey(static fn(int $n): int => ($n % 3 === 0 ? 2 : 0) | ($n % 5 === 0 ? 1 : 0))
    ->map(static fn(int $n, int $k): string => [$n, 'Buzz', 'Fizz', 'Fizz Buzz'][$k].', ')
    ->call(Consumers::usleep(100_000)) //slow down a bit
    ->forEach(STDOUT);