The Ds\Deque::reduce() function is an inbuilt function in PHP which is used to reduce the Deque to a single element using callback function.
public Ds\Deque::reduce( $callback, $initial ) : mixed
Parameters: This function accept two parameters as mentioned above and described below:
- callable: It contains the operation to be performed on the elements of Deque resulting into a single element.
- value: It holds the initial value of carry which will be the result after performing operation on all elements.
Return Value: This function returns the final value returned by the callback function.
Below programs illustrate the Ds\Deque::reduce() function in PHP:
Elements of Deque Ds\Deque Object (  => 10  => 20  => 30  => 40  => 50  => 60 ) Deque after reduced into single element: int(215)
Elements of Deque Ds\Deque Object (  => 10  => 20  => 30  => 40  => 50  => 60 ) Deque after reduced into single element: int(8714461220)
- PHP | Ds\Vector reduce() Function
- PHP | Ds\Set reduce() Function
- PHP | Ds\Map reduce() Function
- PHP | Ds\Sequence reduce() Function
- Ways To Reduce The Loading Time Of Website | Set 1
- Ways To Reduce The Loading Time Of Your Website | Set 2
- Underscore.js | _.reduce() Method
- Reduce the size of an icon during the animation
- TypeScript | Array reduce() Method
- Lodash _.reduce() Method
- How to get the function name inside a function in PHP ?
- PHP 5 vs PHP 7
- PHP | Get PHP configuration information using phpinfo()
- PHP | php.ini File Configuration
- How to import config.php file in a PHP script ?
- PHP | imagecreatetruecolor() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.