code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(45 lines)
1 '\" t
2 .\" Copyright (c) 2026 Bruce Hill
3 .\" All rights reserved.
4 .\"
5 .TH Byte.to 3 2026-03-08 "Tomo man-pages"
6 .SH NAME
7 Byte.to \- iterate over a range of bytes
8 .SH LIBRARY
9 Tomo Standard Library
10 .SH SYNOPSIS
11 .nf
12 .BI Byte.to\ :\ func(first:\ Byte,\ last:\ Byte,\ step:\ Int8?\ =\ none\ ->\ func(->Byte?))
13 .fi
14 .SH DESCRIPTION
15 Returns an iterator function that iterates over the range of bytes 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 Byte The starting value of the range. -
26 last Byte The ending value of the range. -
27 step Int8? 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 byte in the given range (inclusive).
32 .SH EXAMPLES
33 .EX
34 iter := Byte(2).to(4)
35 assert iter() == Byte(2)
36 assert iter() == Byte(3)
37 assert iter() == Byte(4)
38 assert iter() == none
40 assert [x for x in Byte(2).to(5)] == [Byte(2), Byte(3), Byte(4), Byte(5)]
41 assert [x for x in Byte(5).to(2)] == [Byte(5), Byte(4), Byte(3), Byte(2)]
42 assert [x for x in Byte(2).to(5, step=2)] == [Byte(2), Byte(4)]
43 .EE
44 .SH SEE ALSO
45 .BR Tomo-Byte (3)