We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c9aae72 commit d91c080Copy full SHA for d91c080
Private/Split-Every.ps1
@@ -3,15 +3,16 @@ Function Split-Every($list, $count=4) {
3
4
$blocks = [Math]::Floor($list.Count / $count)
5
$leftOver = $list.Count % $count
6
+ $start=0
7
for($i=0; $i -lt $blocks; $i++) {
8
$end = $count * ($i + 1) - 1
9
10
$aggregateList += @(,$list[$start..$end])
11
$start = $end + 1
12
}
13
if($leftOver -gt 0) {
- $aggregateList += @(,$list[$start..($end+$leftOver)])
14
+ $aggregateList += @(,$list[$start..($start+$leftOver-1)])
15
-
16
- $aggregateList
+ If ($list.Count -le $count) {$aggregateList=@(,$aggregateList)}
17
+ $aggregateList
18
0 commit comments