Insert¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
Insert[expr, elem, n] inserts elem at position n in expr.
Examples (2)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (2)¶
Implementation notes¶
builtin_insert (in src/part.c) handles the 3-arg form Insert[expr, elem, pos] by delegating to the helper expr_insert, which inserts elem before position pos (negative indices count from the end, and a position may be a list path for nested insertion), deep-copying the surrounding structure and preserving the original head.
poscan be a single index, a list (path), or a list of paths.Delete[expr, 0]replaces the head withSequence.
Attributes: none registered.
References¶
- Source:
src/part.c - Specification:
docs/spec/builtins/structural-manipulation.md - Tests:
tests/test_packed_list.c - Tests:
tests/test_part.c