functional-php / parallel
Parallel implementation of some higher-order functions.
dev-master
2018-01-27 22:49 UTC
Requires
- php: >=7.0.0
Requires (Dev)
- atoum/atoum: *
Suggests
- krakjoe/pthreads-polyfill: If you are not sure pthreads are available, this polyfill will allow to run the code sequentially without any chance to your code.
This package is auto-updated.
Last update: 2024-12-21 20:30:23 UTC
README
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.
Installation
composer require functional-php/parallel
Basic Usage
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
Testing
You can run the test suite for the library using:
composer test
A test report will be available in the reports
directory.
Contributing
Any contribution welcome :
- Ideas
- Pull requests
- Issues