@@ -250,6 +250,7 @@ will return:
250250<a href =" #shuffled " >shuffled</a >
251251<a href =" #skip " >skip</a >
252252<a href =" #slice " >slice</a >
253+ <a href =" #sliding " >sliding</a >
253254<a href =" #some " >some</a >
254255<a href =" #sort " >sort</a >
255256<a href =" #sorted " >sorted</a >
@@ -488,6 +489,7 @@ will return:
488489* [ rekey()] ( #rekey ) : Changes the keys according to the passed function
489490* [ replace()] ( #replace ) : Replaces elements recursively
490491* [ rtrim()] ( #rtrim ) : Removes the passed characters from the right of all strings
492+ * [ sliding()] ( #sliding ) : Returns a new map containing sliding windows of the original map
491493* [ splice()] ( #splice ) : Replaces a slice by new elements
492494* [ strAfter()] ( #strafter ) : Returns the strings after the passed value
493495* [ strBefore()] ( #strbefore ) : Returns the strings before the passed value
@@ -5463,6 +5465,36 @@ Map::from( ['a', 'b', 'c', 'd'] )->slice( -2, -1 );
54635465* [ take()] ( #take ) - Returns a new map with the given number of items.
54645466
54655467
5468+ ### sliding()
5469+
5470+ Returns a new map containing sliding windows of the original map.
5471+
5472+ ``` php
5473+ public function sliding( int $size = 2, int $step = 1 ) : self
5474+ ```
5475+
5476+ * @param ** int** $size Size of each window
5477+ * @param ** int** $step Step size to move the window
5478+ * @return ** self< ; int,array< ; int| ; string,mixed> ;> ; ** New map containing arrays for each window
5479+
5480+ ** Examples:**
5481+
5482+ ``` php
5483+ Map::from( [1, 2, 3, 4] )->sliding( 2 );
5484+ // [
5485+ // [0 => 1, 1 => 2],
5486+ // [1 => 2, 2 => 3],
5487+ // [2 => 3, 3 => 4]
5488+ // ]
5489+
5490+ Map::from( [1, 2, 3, 4] )->sliding( 3, 2 );
5491+ // [
5492+ // [0 => 1, 1 => 2, 2 => 3],
5493+ // [2 => 3, 3 => 4, 4 => 5]
5494+ // ]
5495+ ```
5496+
5497+
54665498### some()
54675499
54685500Tests if at least one element passes the test or is part of the map.
0 commit comments