/array/insert
stdInserts the given item to the array at a specific index.
Type signature
(index: number) => <T>(item: T) => ([...xs]: T[]) => T[]
Examples
insert(0)("d")(["a", "b", "c"]);
// ⇒ ['d', 'a', 'b', 'c']
Try in REPL
insert(1)("d")(["a", "b", "c"]);
// ⇒ ['a', 'd', 'b', 'c']
Try in REPL
Questions
- How to insert an element to an array at a given position?