Last active
November 18, 2019 20:35
-
-
Save ImkeF/2d494c6b6ecdb059b76a69a200edb200 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let func = | |
(inputList as list, chunkSize as number) => | |
let | |
ListSelectPositions = (SelectionList as list, ListOfPositions as list) => List.Transform(ListOfPositions, each try SelectionList{_} otherwise null), | |
Source = inputList, | |
ChunkSize = chunkSize, | |
Count = Number.RoundUp(List.Count(Source)/ChunkSize), | |
Chunks = {1..Count}, | |
Positions = List.Transform(Chunks, each {_*ChunkSize-ChunkSize.._*ChunkSize-1}), | |
Allocate = List.Transform(Positions, each ListSelectPositions(Source, _)) | |
in | |
Allocate | |
, documentation = [ | |
Documentation.Name = " List.ChunkUp | |
", Documentation.Description = " Chunks up an <code>inputList</code> into groups of <code>chunkSize</code>. | |
" , Documentation.LongDescription = " Chunks up an <code>inputList</code> into groups of <code>chunkSize</code>. | |
", Documentation.Category = " List | |
", Documentation.Source = " local | |
", Documentation.Author = " Imke Feldmann: www.TheBIccountant.com . | |
", Documentation.Examples = {[Description = " | |
" , Code = " List.ChunkUp({1, 2, 3, 4, 5}, 2) | |
", Result = " {{1,2}, {3,4}, {5, null}} | |
"]}] | |
in | |
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment