Skip to content

Latest commit

 

History

History
28 lines (17 loc) · 518 Bytes

reverse.md

File metadata and controls

28 lines (17 loc) · 518 Bytes

reverse

Description

Returns a reversed collection preserving its keys.

Passing a Generator to this function will work but it does not provide any improvement against a simple Traversable because to reach the last one is necessary iterate among all the items

Parameters

coll
Collection to be reversed.

Examples

<?php

use function Lambdish\Phunctional\reverse;

return reverse([1, 2, 3, 4, 5]);
            
// => [4 => 5, 3 => 4, 2 => 3, 1 => 2, 0 => 1]