docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Compose a single, ordered queue from nested sections with configurable trimming and end-of-queue reversal. All operations must be immutable, leaving the provided arrays unchanged.
Trim each section by dropping the first drop items (default: 0) and, if take is provided, keeping only the first take items of what remains. The processed sections are concatenated in their original order into a flat queue.
[[1, 2, 3], [4, 5], [6, 7, 8]] with { drop: 1, take: 2 }, the composed queue is [2, 3, 5, 7, 8], leaving the original sections unchanged. @testAfter flattening, if reverseTailCount is provided and greater than zero, reverse only the final reverseTailCount items of the queue, preserving the order of earlier items.
[[1, 2], [3, 4, 5]] with { reverseTailCount: 3 }, the composed queue is [1, 2, 5, 4, 3]. @testExpose a helper that splits any composed queue at a pivot index into [before, after], where before contains elements up to but not including the pivot position.
[10, 20, 30, 40, 50] at pivot 3 returns [[10, 20, 30], [40, 50]]. @testexport type ComposeOptions = {
drop?: number,
take?: number,
reverseTailCount?: number,
};
/**
* Builds a queue from nested sections without mutating inputs.
*/
export function composeQueue(
sections: Array<Array<any>>,
options?: ComposeOptions
): Array<any>;
/**
* Splits a queue at the given pivot index into [before, after].
*/
export function splitQueue(
queue: Array<any>,
pivotIndex: number
): [Array<any>, Array<any>];Functional list utilities for slicing, concatenation, mapping over lists, and flattening nested collections.