# fill-range Return a new list (vector) with the elements in `[start, end)` replaced by `$val`, built in one allocation — replaces a `set-nth` loop over a contiguous range. Negative indices count from the end. ## Syntax
[fill-range $list $start $end $val]
## Parameters - `$list` — A persistent list/vector; flat arrays from `array` are not accepted. - `$start` — Start index, inclusive (number); negative counts from the end. - `$end` — End index, exclusive (number); negative counts from the end. - `$val` — Replacement value. ## Examples
[fill-range @{1 2 3 4 5} 1 3 :x]   # → @{1 :x :x 4 5}
[fill-range @{1 2 3} -2 -1 :q]     # → @{1 :q 3}
[fill-range @{1 2 3} 2 0 :q]       # → @{1 2 3}  (inverted range: unchanged)
## Returns A new vector with the range filled; the input unchanged for an empty, inverted, or fully out-of-range span; nil when `$list` is not a list/vector. ## See Also `set-nth`, `slice`, `nth`, `replicate`