# replicate
Build a vector of `$n` copies of `$val` in a single allocation — use it instead
of an append loop for pre-filling. Negative `$n` is treated as 0; a fractional
`$n` truncates toward zero.
## Syntax
[replicate $val $n]
## Parameters
- `$val` — Value to copy.
- `$n` — Count (number, ≥ 0).
## Examples
[replicate :x 3] # → @{:x :x :x} [replicate 0 4] # → @{0 0 0 0} [replicate :x 0] # → @{} [replicate :x -2] # → @{}
## Returns
A vector holding `$n` references to `$val`. Arity is exactly 2; a non-number
`$n` returns nil.
## See Also
`array-of`, `range`, `repeat`, `append`