code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(46 lines)
1 '\" t
2 .\" Copyright (c) 2026 Bruce Hill
3 .\" All rights reserved.
4 .\"
5 .TH Int.to 3 2026-01-19 "Tomo man-pages"
6 .SH NAME
7 Int.to \- iterate a range of integers
8 .SH LIBRARY
9 Tomo Standard Library
10 .SH SYNOPSIS
11 .nf
12 .BI Int.to\ :\ func(first:\ Int,\ last:\ Int,\ step:\ Int?\ =\ none\ ->\ func(->Int?))
13 .fi
14 .SH DESCRIPTION
15 Returns an iterator function that iterates over the range of numbers specified.
18 .SH ARGUMENTS
20 .TS
21 allbox;
22 lb lb lbx lb
23 l l l l.
24 Name Type Description Default
25 first Int The starting value of the range. -
26 last Int The ending value of the range. -
27 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
28 .TE
29 .SH RETURN
30 An iterator function that returns each integer in the given range (inclusive).
32 .SH EXAMPLES
33 .EX
34 iter := 2.to(5)
35 assert iter() == 2
36 assert iter() == 3
37 assert iter() == 4
38 assert iter() == 5
39 assert iter() == none
41 assert [x for x in 2.to(5)] == [2, 3, 4, 5]
42 assert [x for x in 5.to(2)] == [5, 4, 3, 2]
43 assert [x for x in 2.to(5, step=2)] == [2, 4]
44 .EE
45 .SH SEE ALSO
46 .BR Tomo-Int (3)