blob: e5ba915860539a971d84b1b81e7609fb91ea3678 (
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
46
|
'\" t
.\" Copyright (c) 2026 Bruce Hill
.\" All rights reserved.
.\"
.TH Int.to 3 2026-01-19 "Tomo man-pages"
.SH NAME
Int.to \- iterate a range of integers
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI Int.to\ :\ func(first:\ Int,\ last:\ Int,\ step:\ Int?\ =\ none\ ->\ func(->Int?))
.fi
.SH DESCRIPTION
Returns an iterator function that iterates over the range of numbers specified.
.SH ARGUMENTS
.TS
allbox;
lb lb lbx lb
l l l l.
Name Type Description Default
first Int The starting value of the range. -
last Int The ending value of the range. -
step Int? An optional step size to use. If unspecified or \fBnone\fR, the step will be inferred to be \fB+1\fR if \fBlast >= first\fR, otherwise \fB-1\fR. none
.TE
.SH RETURN
An iterator function that returns each integer in the given range (inclusive).
.SH EXAMPLES
.EX
iter := 2.to(5)
assert iter() == 2
assert iter() == 3
assert iter() == 4
assert iter() == 5
assert iter() == none
assert [x for x in 2.to(5)] == [2, 3, 4, 5]
assert [x for x in 5.to(2)] == [5, 4, 3, 2]
assert [x for x in 2.to(5, step=2)] == [2, 4]
.EE
.SH SEE ALSO
.BR Tomo-Int (3)
|