Parallel implementation of the higher-order functions map
, filter
and fold
using the
phtreads library. This way the computation is distributed
across multiple threads so that the whole computational power of the computer can be used.
See the pthreads library requirement. If you are not sure they will be satisfied, install the polyfill.
composer require functional-php/parallel
use FunctionalPHP\Parallel as p;
p\map(4, function($i) { return $i + 2; }, [1, 2, 3, 4]);
// will return [3, 4, 5, 6]
p\filter(4, function($i) { return $i % 2 == 0; }, [1, 2, 3, 4]);
// will return [2, 4]
p\fold(4, function($a, $b) { return $a + $b; }, [1, 2, 3, 4], 0);
// will return 10
You can run the test suite for the library using:
composer test
A test report will be available in the reports
directory.
Any contribution welcome :
- Ideas
- Pull requests
- Issues