aboutsummaryrefslogtreecommitdiff
path: root/man/man3/tomo-List.slice.3
blob: ebc38f7b70197568137872b6386d17991c755b57 (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
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH List.slice 3 2025-04-27 "Tomo man-pages"
.SH NAME
List.slice \- get a slice of a list
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI List.slice\ :\ func(list:\ [T],\ from:\ Int,\ to:\ Int\ ->\ [T])
.fi
.SH DESCRIPTION
Returns a slice of the list spanning the given indices (inclusive).


.SH ARGUMENTS

.TS
allbox;
lb lb lbx lb
l l l l.
Name	Type	Description	Default
list	[T]	The original list. 	-
from	Int	The first index to include. 	-
to	Int	The last index to include. 	-
.TE
.SH RETURN
A new list spanning the given indices. Note: negative indices are counted from the back of the list, so `-1` refers to the last element, `-2` the second-to-last, and so on.

.SH EXAMPLES
.EX
>> [10, 20, 30, 40, 50].slice(2, 4)
= [20, 30, 40]

>> [10, 20, 30, 40, 50].slice(-3, -2)
= [30, 40]
.EE