blob: 378f8d4958857391d7bb388f97b289d3ff71516c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH List.insert 3 2025-04-19T14:52:07.133915 "Tomo man-pages"
.SH NAME
List.insert \- Inserts an element at a specified position in the list.
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI List.insert\ :\ func(list:\ @[T],\ item:\ T,\ at:\ Int\ =\ 0\ ->\ Void)
.fi
.SH DESCRIPTION
Inserts an element at a specified position in the list.
.TS
allbox;
lb lb lbx lb
l l l l.
Name Type Description Default
list @[T] The mutable reference to the list. -
item T The item to be inserted. -
at Int The index at which to insert the item. 0
.TE
.SH RETURN
Nothing.
.SH NOTES
Since indices are 1-indexed and negative indices mean "starting from the back", an index of `0` means "after the last item".
.SH EXAMPLES
.EX
>> list := [10, 20]
>> list.insert(30)
>> list
= [10, 20, 30]
>> list.insert(999, at=2)
>> list
= [10, 999, 20, 30]
.EE
|