diff options
Diffstat (limited to 'man')
215 files changed, 7621 insertions, 0 deletions
diff --git a/man/man1/tomo.1 b/man/man1/tomo.1 new file mode 100644 index 00000000..bbc90f8e --- /dev/null +++ b/man/man1/tomo.1 @@ -0,0 +1,75 @@ +.\" Automatically generated by Pandoc 3.1.12.1 +.\" +.TH "TOMO" "1" "June 11, 2024" "" "" +.SH NAME +tomo \- The programming language of tomorrow. +.SH SYNOPSIS +.TP +Run the REPL: +\f[B]tomo\f[R] +.TP +Run a program: +\f[B]tomo\f[R] \f[I]program.tm\f[R] [[\f[B]\-\-\f[R]] +\f[I]args\&...\f[R]] +.TP +Transpile tomo files to C files: +\f[B]tomo\f[R] \f[B]\-t\f[R] \f[I]file1.tm\f[R] \f[I]file2.tm\f[R]\&... +.TP +Compile files to static object files: +\f[B]tomo\f[R] \f[B]\-c\f[R] \f[I]file1.tm\f[R] \f[I]file2.tm\f[R]\&... +.TP +Compile file to an executable: +\f[B]tomo\f[R] \f[B]\-e\f[R] \f[I]file1.tm\f[R] +.TP +Build a shared library: +\f[B]tomo\f[R] \f[B]\-s=\f[R]\f[I]mylib.1.2.3\f[R] \f[I]file1.tm\f[R] +\f[I]file2.tm\f[R]\&... +.SH DESCRIPTION +Tomo is a programming language that is statically typed, compiled, +small, and garbage\-collected, with concise syntax and built\-in support +for high\-performance, low\-overhead datastructures. +It compiles by first outputting C code, which is then compiled using a C +compiler of your choice. +.SH OPTIONS +.TP +\f[B]\-h\f[R], \f[B]\-\-help\f[R] +Print the usage and exit. +.TP +\f[B]\-t\f[R], \f[B]\-\-transpile\f[R] +Transpile the input files to C code without compiling them. +.TP +\f[B]\-c\f[R], \f[B]\-\-compile\-obj\f[R] +Compile the input files to static objects, rather than running them. +.TP +\f[B]\-e\f[R], \f[B]\-\-compile\-exe\f[R] +Compile the input file to an executable. +.TP +\f[B]\-L\f[R], \f[B]\-\-library\f[R] +Compile the input files to a shared library file and header. +.TP +\f[B]\-I\f[R], \f[B]\-\-install\f[R] +Install the compiled executable or library. +.TP +\f[B]\-C\f[R] \f[I]\f[R], \f[B]\-\-show\-codegen\f[R] \f[I]\f[R] +Set a program (e.g.\ \f[B]cat\f[R] or \f[B]bat\f[R]) to display the +generated code +.TP +\f[B]\-\-c\-compiler\f[R] +Set which C compiler is used. +.TP +\f[B]\-O\f[R] \f[B]level\f[R], \f[B]\-\-optimization\f[R] \f[B]level\f[R] +Set the optimization level. +.TP +\f[B]\-v\f[R], \f[B]\-\-verbose\f[R] +Print extra verbose output. +.TP +\f[B]\-r\f[R], \f[B]\-\-run\f[R] +Run an installed tomo program from +\f[B]\[ti]/.local/share/tomo/installed\f[R]. +.SS ENVIRONMENT VARIABLES +Some options can be configured by setting environment variables. +.TP +\f[B]CC=\f[R]\f[I]c\-compiler\f[R] +Set which C compiler is used. +.SH AUTHORS +Bruce Hill (\f[I]bruce\[at]bruce\-hill.com\f[R]). diff --git a/man/man3/tomo-Bool.parse.3 b/man/man3/tomo-Bool.parse.3 new file mode 100644 index 00000000..6c722b99 --- /dev/null +++ b/man/man3/tomo-Bool.parse.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Bool.parse 3 2025-04-19T14:30:40.359614 "Tomo man-pages" +.SH NAME +Bool.parse \- Converts a string representation of a boolean value into a boolean. Acceptable boolean values are case-insensitive variations of `yes`/`no`, `y`/`n`, `true`/`false`, `on`/`off`. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Bool.parse : func(text: Text -> Bool?)" +.fi + +.SH DESCRIPTION +Converts a string representation of a boolean value into a boolean. Acceptable boolean values are case-insensitive variations of `yes`/`no`, `y`/`n`, `true`/`false`, `on`/`off`. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The string containing the boolean value. - +.TE +.SH RETURN +`yes` if the string matches a recognized truthy boolean value; otherwise return `no`. + +.SH EXAMPLES +.EX +>> Bool.parse("yes") += yes : Bool? +>> Bool.parse("no") += no : Bool? +>> Bool.parse("???") += none : Bool? +.EE diff --git a/man/man3/tomo-Byte.hex.3 b/man/man3/tomo-Byte.hex.3 new file mode 100644 index 00000000..f55fde16 --- /dev/null +++ b/man/man3/tomo-Byte.hex.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Byte.hex 3 2025-04-19T14:30:40.360114 "Tomo man-pages" +.SH NAME +Byte.hex \- Convert a byte to a hexidecimal text representation. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Byte.hex : func(byte: Byte, uppercase: Bool = yes, prefix: Bool = no -> Text)" +.fi + +.SH DESCRIPTION +Convert a byte to a hexidecimal text representation. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +byte Byte The byte to convert to hex. - +uppercase Bool Whether or not to use uppercase hexidecimal letters. yes +prefix Bool Whether or not to prepend a `0x` prefix. no +.TE +.SH RETURN +The byte as a hexidecimal text. + +.SH EXAMPLES +.EX +>> Byte(18).hex() += "0x12" +.EE diff --git a/man/man3/tomo-Byte.is_between.3 b/man/man3/tomo-Byte.is_between.3 new file mode 100644 index 00000000..c963d054 --- /dev/null +++ b/man/man3/tomo-Byte.is_between.3 @@ -0,0 +1,40 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Byte.is_between 3 2025-04-19T14:30:40.360176 "Tomo man-pages" +.SH NAME +Byte.is_between \- Determines if an integer is between two numbers (inclusive). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Byte.is_between : func(x: Byte, low: Byte, high: Byte -> Bool)" +.fi + +.SH DESCRIPTION +Determines if an integer is between two numbers (inclusive). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Byte The integer to be checked. - +low Byte The lower bound to check (inclusive). - +high Byte The upper bound to check (inclusive). - +.TE +.SH RETURN +`yes` if `low <= x and x <= high`, otherwise `no` + +.SH EXAMPLES +.EX +>> Byte(7).is_between(1, 10) += yes +>> Byte(7).is_between(100, 200) += no +>> Byte(7).is_between(1, 7) += yes +.EE diff --git a/man/man3/tomo-Byte.parse.3 b/man/man3/tomo-Byte.parse.3 new file mode 100644 index 00000000..76e35a3a --- /dev/null +++ b/man/man3/tomo-Byte.parse.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Byte.parse 3 2025-04-19T14:30:40.360223 "Tomo man-pages" +.SH NAME +Byte.parse \- Parse a byte literal from text. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Byte.parse : func(text: Text -> Byte?)" +.fi + +.SH DESCRIPTION +Parse a byte literal from text. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to parse. - +.TE +.SH RETURN +The byte parsed from the text, if successful, otherwise `none`. + +.SH EXAMPLES +.EX +>> Byte.parse("5") += Byte(5)? +>> Byte.parse("asdf") += none +.EE diff --git a/man/man3/tomo-Byte.to.3 b/man/man3/tomo-Byte.to.3 new file mode 100644 index 00000000..149c2126 --- /dev/null +++ b/man/man3/tomo-Byte.to.3 @@ -0,0 +1,43 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Byte.to 3 2025-04-19T14:30:40.360261 "Tomo man-pages" +.SH NAME +Byte.to \- Returns an iterator function that iterates over the range of bytes specified. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Byte.to : func(first: Byte, last: Byte, step: Byte? = none -> func(->Byte?))" +.fi + +.SH DESCRIPTION +Returns an iterator function that iterates over the range of bytes specified. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +first Byte The starting value of the range. - +last Byte The ending value of the range. - +step Byte? An optional step size to use. If unspecified or `none`, the step will be inferred to be `+1` if `last >= first`, otherwise `-1`. none +.TE +.SH RETURN +An iterator function that returns each byte in the given range (inclusive). + +.SH EXAMPLES +.EX +>> Byte(2).to(5) += func(->Byte?) +>> [x for x in Byte(2).to(5)] += [Byte(2), Byte(3), Byte(4), Byte(5)] +>> [x for x in Byte(5).to(2)] += [Byte(5), Byte(4), Byte(3), Byte(2)] + +>> [x for x in Byte(2).to(5, step=2)] += [Byte(2), Byte(4)] +.EE diff --git a/man/man3/tomo-Int.abs.3 b/man/man3/tomo-Int.abs.3 new file mode 100644 index 00000000..7ef53d0b --- /dev/null +++ b/man/man3/tomo-Int.abs.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.abs 3 2025-04-19T14:30:40.360304 "Tomo man-pages" +.SH NAME +Int.abs \- Calculates the absolute value of an integer. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.abs : func(x: Int -> Int)" +.fi + +.SH DESCRIPTION +Calculates the absolute value of an integer. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Int The integer whose absolute value is to be calculated. - +.TE +.SH RETURN +The absolute value of `x`. + +.SH EXAMPLES +.EX +>> (-10).abs() += 10 +.EE diff --git a/man/man3/tomo-Int.choose.3 b/man/man3/tomo-Int.choose.3 new file mode 100644 index 00000000..aeb1d4b7 --- /dev/null +++ b/man/man3/tomo-Int.choose.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.choose 3 2025-04-19T14:30:40.360341 "Tomo man-pages" +.SH NAME +Int.choose \- Computes the binomial coefficient of the given numbers (the equivalent of `n` choose `k` in combinatorics). This is equal to `n.factorial()/(k.factorial() * (n-k).factorial())`. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.choose : func(n: Int, k: Int -> Int)" +.fi + +.SH DESCRIPTION +Computes the binomial coefficient of the given numbers (the equivalent of `n` choose `k` in combinatorics). This is equal to `n.factorial()/(k.factorial() * (n-k).factorial())`. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +n Int The number of things to choose from. - +k Int The number of things to be chosen. - +.TE +.SH RETURN +The binomial coefficient, equivalent to the number of ways to uniquely choose `k` objects from among `n` objects, ignoring order. + +.SH EXAMPLES +.EX +>> (4).choose(2) += 6 +.EE diff --git a/man/man3/tomo-Int.clamped.3 b/man/man3/tomo-Int.clamped.3 new file mode 100644 index 00000000..d65549dd --- /dev/null +++ b/man/man3/tomo-Int.clamped.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.clamped 3 2025-04-19T14:30:40.360382 "Tomo man-pages" +.SH NAME +Int.clamped \- Returns the given number clamped between two values so that it is within that range. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.clamped : func(x: Int, low: Int, high: Int -> Int)" +.fi + +.SH DESCRIPTION +Returns the given number clamped between two values so that it is within that range. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Int The integer to clamp. - +low Int The lowest value the result can take. - +high Int The highest value the result can take. - +.TE +.SH RETURN +The first argument clamped between the other two arguments. + +.SH EXAMPLES +.EX +>> (2).clamped(5, 10) += 5 +.EE diff --git a/man/man3/tomo-Int.factorial.3 b/man/man3/tomo-Int.factorial.3 new file mode 100644 index 00000000..0cbe1fb3 --- /dev/null +++ b/man/man3/tomo-Int.factorial.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.factorial 3 2025-04-19T14:30:40.360421 "Tomo man-pages" +.SH NAME +Int.factorial \- Computes the factorial of an integer. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.factorial : func(n: Int -> Text)" +.fi + +.SH DESCRIPTION +Computes the factorial of an integer. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +n Int The integer to compute the factorial of. - +.TE +.SH RETURN +The factorial of the given integer. + +.SH EXAMPLES +.EX +>> (10).factorial() += 3628800 +.EE diff --git a/man/man3/tomo-Int.format.3 b/man/man3/tomo-Int.format.3 new file mode 100644 index 00000000..afe76967 --- /dev/null +++ b/man/man3/tomo-Int.format.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.format 3 2025-04-19T14:30:40.360458 "Tomo man-pages" +.SH NAME +Int.format \- Formats an integer as a string with a specified number of digits. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.format : func(i: Int, digits: Int = 0 -> Text)" +.fi + +.SH DESCRIPTION +Formats an integer as a string with a specified number of digits. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +i Int The integer to be formatted. - +digits Int The minimum number of digits to which the integer should be padded. 0 +.TE +.SH RETURN +A string representation of the integer, padded to the specified number of digits. + +.SH EXAMPLES +.EX +>> (42).format(digits=5) += "00042" +.EE diff --git a/man/man3/tomo-Int.hex.3 b/man/man3/tomo-Int.hex.3 new file mode 100644 index 00000000..ded16562 --- /dev/null +++ b/man/man3/tomo-Int.hex.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.hex 3 2025-04-19T14:30:40.360505 "Tomo man-pages" +.SH NAME +Int.hex \- Converts an integer to its hexadecimal representation. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.hex : func(i: Int, digits: Int = 0, uppercase: Bool = yes, prefix: Bool = yes -> Text)" +.fi + +.SH DESCRIPTION +Converts an integer to its hexadecimal representation. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +i Int The integer to be converted. - +digits Int The minimum number of digits in the output string. 0 +uppercase Bool Whether to use uppercase letters for hexadecimal digits. yes +prefix Bool Whether to include a "0x" prefix. yes +.TE +.SH RETURN +The hexadecimal string representation of the integer. + +.SH EXAMPLES +.EX +>> (255).hex(digits=4, uppercase=yes, prefix=yes) += "0x00FF" +.EE diff --git a/man/man3/tomo-Int.is_between.3 b/man/man3/tomo-Int.is_between.3 new file mode 100644 index 00000000..4c940ccd --- /dev/null +++ b/man/man3/tomo-Int.is_between.3 @@ -0,0 +1,40 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.is_between 3 2025-04-19T14:30:40.360548 "Tomo man-pages" +.SH NAME +Int.is_between \- Determines if an integer is between two numbers (inclusive). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.is_between : func(x: Int, low: Int, high: Int -> Bool)" +.fi + +.SH DESCRIPTION +Determines if an integer is between two numbers (inclusive). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Int The integer to be checked. - +low Int The lower bound to check (inclusive). - +high Int The upper bound to check (inclusive). - +.TE +.SH RETURN +`yes` if `low <= x and x <= high`, otherwise `no` + +.SH EXAMPLES +.EX +>> (7).is_between(1, 10) += yes +>> (7).is_between(100, 200) += no +>> (7).is_between(1, 7) += yes +.EE diff --git a/man/man3/tomo-Int.is_prime.3 b/man/man3/tomo-Int.is_prime.3 new file mode 100644 index 00000000..4cb59dd7 --- /dev/null +++ b/man/man3/tomo-Int.is_prime.3 @@ -0,0 +1,40 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.is_prime 3 2025-04-19T14:30:40.360587 "Tomo man-pages" +.SH NAME +Int.is_prime \- Determines if an integer is a prime number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.is_prime : func(x: Int, reps: Int = 50 -> Bool)" +.fi + +.SH DESCRIPTION +Determines if an integer is a prime number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Int The integer to be checked. - +reps Int The number of repetitions for primality tests. 50 +.TE +.SH RETURN +`yes` if `x` is a prime number, `no` otherwise. + +.SH NOTES +This function is _probabilistic_. With the default arguments, the chances of getting an incorrect answer are astronomically small (on the order of 10^(-30)). See [the GNU MP docs](https://gmplib.org/manual/Number-Theoretic-Functions#index-mpz_005fprobab_005fprime_005fp) for more details. + +.SH EXAMPLES +.EX +>> (7).is_prime() += yes +>> (6).is_prime() += no +.EE diff --git a/man/man3/tomo-Int.next_prime.3 b/man/man3/tomo-Int.next_prime.3 new file mode 100644 index 00000000..7890d0bc --- /dev/null +++ b/man/man3/tomo-Int.next_prime.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.next_prime 3 2025-04-19T14:30:40.360625 "Tomo man-pages" +.SH NAME +Int.next_prime \- Finds the next prime number greater than the given integer. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.next_prime : func(x: Int -> Int)" +.fi + +.SH DESCRIPTION +Finds the next prime number greater than the given integer. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Int The integer after which to find the next prime. - +.TE +.SH RETURN +The next prime number greater than `x`. + +.SH NOTES +This function is _probabilistic_, but the chances of getting an incorrect answer are astronomically small (on the order of 10^(-30)). See [the GNU MP docs](https://gmplib.org/manual/Number-Theoretic-Functions#index-mpz_005fprobab_005fprime_005fp) for more details. + +.SH EXAMPLES +.EX +>> (11).next_prime() += 13 +.EE diff --git a/man/man3/tomo-Int.octal.3 b/man/man3/tomo-Int.octal.3 new file mode 100644 index 00000000..244e3320 --- /dev/null +++ b/man/man3/tomo-Int.octal.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.octal 3 2025-04-19T14:30:40.360662 "Tomo man-pages" +.SH NAME +Int.octal \- Converts an integer to its octal representation. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.octal : func(i: Int, digits: Int = 0, prefix: Bool = yes -> Text)" +.fi + +.SH DESCRIPTION +Converts an integer to its octal representation. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +i Int The integer to be converted. - +digits Int The minimum number of digits in the output string. 0 +prefix Bool Whether to include a "0o" prefix. yes +.TE +.SH RETURN +The octal string representation of the integer. + +.SH EXAMPLES +.EX +>> (64).octal(digits=4, prefix=yes) += "0o0100" +.EE diff --git a/man/man3/tomo-Int.onward.3 b/man/man3/tomo-Int.onward.3 new file mode 100644 index 00000000..2cb295f9 --- /dev/null +++ b/man/man3/tomo-Int.onward.3 @@ -0,0 +1,39 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.onward 3 2025-04-19T14:30:40.360700 "Tomo man-pages" +.SH NAME +Int.onward \- Return an iterator that counts infinitely from the starting integer (with an optional step size). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.onward : func(first: Int, step: Int = 1 -> Text)" +.fi + +.SH DESCRIPTION +Return an iterator that counts infinitely from the starting integer (with an optional step size). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +first Int The starting integer. - +step Int The increment step size. 1 +.TE +.SH RETURN +An iterator function that counts onward from the starting integer. + +.SH EXAMPLES +.EX +nums : &[Int] = &[] +for i in (5).onward() +nums.insert(i) +stop if i == 10 +>> nums[] += [5, 6, 7, 8, 9, 10] +.EE diff --git a/man/man3/tomo-Int.parse.3 b/man/man3/tomo-Int.parse.3 new file mode 100644 index 00000000..adb64d95 --- /dev/null +++ b/man/man3/tomo-Int.parse.3 @@ -0,0 +1,44 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.parse 3 2025-04-19T14:30:40.360757 "Tomo man-pages" +.SH NAME +Int.parse \- Converts a text representation of an integer into an integer. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.parse : func(text: Text -> Int?)" +.fi + +.SH DESCRIPTION +Converts a text representation of an integer into an integer. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text containing the integer. - +.TE +.SH RETURN +The integer represented by the text. If the given text contains a value outside of the representable range or if the entire text can't be parsed as an integer, `none` will be returned. + +.SH EXAMPLES +.EX +>> Int.parse("123") += 123 : Int? +>> Int.parse("0xFF") += 255 : Int? + +# Can't parse: +>> Int.parse("asdf") += none : Int? + +# Outside valid range: +>> Int8.parse("9999999") += none : Int8? +.EE diff --git a/man/man3/tomo-Int.prev_prime.3 b/man/man3/tomo-Int.prev_prime.3 new file mode 100644 index 00000000..50c62575 --- /dev/null +++ b/man/man3/tomo-Int.prev_prime.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.prev_prime 3 2025-04-19T14:30:40.360801 "Tomo man-pages" +.SH NAME +Int.prev_prime \- Finds the previous prime number less than the given integer. If there is no previous prime number (i.e. if a number less than `2` is provided), then the function will create a runtime error. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.prev_prime : func(x: Int -> Int?)" +.fi + +.SH DESCRIPTION +Finds the previous prime number less than the given integer. If there is no previous prime number (i.e. if a number less than `2` is provided), then the function will create a runtime error. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Int The integer before which to find the previous prime. - +.TE +.SH RETURN +The previous prime number less than `x`, or `none` if `x` is less than 2. + +.SH NOTES +This function is _probabilistic_, but the chances of getting an incorrect answer are astronomically small (on the order of 10^(-30)). See [the GNU MP docs](https://gmplib.org/manual/Number-Theoretic-Functions#index-mpz_005fprobab_005fprime_005fp) for more details. + +.SH EXAMPLES +.EX +>> (11).prev_prime() += 7 +.EE diff --git a/man/man3/tomo-Int.sqrt.3 b/man/man3/tomo-Int.sqrt.3 new file mode 100644 index 00000000..8e6aba1d --- /dev/null +++ b/man/man3/tomo-Int.sqrt.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.sqrt 3 2025-04-19T14:30:40.360844 "Tomo man-pages" +.SH NAME +Int.sqrt \- Calculates the nearest square root of an integer. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Int.sqrt : func(x: Int -> Int)" +.fi + +.SH DESCRIPTION +Calculates the nearest square root of an integer. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Int The integer whose square root is to be calculated. - +.TE +.SH RETURN +The integer part of the square root of `x`. + +.SH EXAMPLES +.EX +>> (16).sqrt() += 4 +>> (17).sqrt() += 4 +.EE diff --git a/man/man3/tomo-Int.to.3 b/man/man3/tomo-Int.to.3 new file mode 100644 index 00000000..53b6b0ff --- /dev/null +++ b/man/man3/tomo-Int.to.3 @@ -0,0 +1,43 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Int.to 3 2025-04-19T14:30:40.360881 "Tomo man-pages" +.SH NAME +Int.to \- Returns an iterator function that iterates over the range of numbers specified. + +.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. + + +.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 `none`, the step will be inferred to be `+1` if `last >= first`, otherwise `-1`. none +.TE +.SH RETURN +An iterator function that returns each integer in the given range (inclusive). + +.SH EXAMPLES +.EX +>> (2).to(5) += func(->Int?) +>> [x for x in (2).to(5)] += [2, 3, 4, 5] +>> [x for x in (5).to(2)] += [5, 4, 3, 2] + +>> [x for x in (2).to(5, step=2)] += [2, 4] +.EE diff --git a/man/man3/tomo-List.binary_search.3 b/man/man3/tomo-List.binary_search.3 new file mode 100644 index 00000000..d5cbbad5 --- /dev/null +++ b/man/man3/tomo-List.binary_search.3 @@ -0,0 +1,41 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.binary_search 3 2025-04-19T14:30:40.360924 "Tomo man-pages" +.SH NAME +List.binary_search \- Performs a binary search on a sorted list. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.binary_search : func(list: [T], by: func(x,y:&T->Int32) = T.compare -> Int)" +.fi + +.SH DESCRIPTION +Performs a binary search on a sorted list. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The sorted list to search. - +by func(x,y:&T->Int32) The comparison function used to determine order. If not specified, the default comparison function for the item type will be used. T.compare +.TE +.SH RETURN +Assuming the input list is sorted according to the given comparison function, return the index where the given item would be inserted to maintain the sorted order. That is, if the item is found, return its index, otherwise return the place where it would be found if it were inserted and the list were sorted. + +.SH EXAMPLES +.EX +>> [1, 3, 5, 7, 9].binary_search(5) += 3 + +>> [1, 3, 5, 7, 9].binary_search(-999) += 1 + +>> [1, 3, 5, 7, 9].binary_search(999) += 6 +.EE diff --git a/man/man3/tomo-List.by.3 b/man/man3/tomo-List.by.3 new file mode 100644 index 00000000..eaefd4c3 --- /dev/null +++ b/man/man3/tomo-List.by.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.by 3 2025-04-19T14:30:40.360962 "Tomo man-pages" +.SH NAME +List.by \- Creates a new list with elements spaced by the specified step value. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.by : func(list: [T], step: Int -> [T])" +.fi + +.SH DESCRIPTION +Creates a new list with elements spaced by the specified step value. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The original list. - +step Int The step value for selecting elements. - +.TE +.SH RETURN +A new list with every `step`-th element from the original list. + +.SH EXAMPLES +.EX +>> [1, 2, 3, 4, 5, 6].by(2) += [1, 3, 5] +.EE diff --git a/man/man3/tomo-List.clear.3 b/man/man3/tomo-List.clear.3 new file mode 100644 index 00000000..687d03b2 --- /dev/null +++ b/man/man3/tomo-List.clear.3 @@ -0,0 +1,33 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.clear 3 2025-04-19T14:30:40.361001 "Tomo man-pages" +.SH NAME +List.clear \- Clears all elements from the list. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.clear : func(list: @[T] -> Void)" +.fi + +.SH DESCRIPTION +Clears all elements from the list. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list @[T] The mutable reference to the list to be cleared. - +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +>> my_list.clear() +.EE diff --git a/man/man3/tomo-List.counts.3 b/man/man3/tomo-List.counts.3 new file mode 100644 index 00000000..bffe397c --- /dev/null +++ b/man/man3/tomo-List.counts.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.counts 3 2025-04-19T14:30:40.361035 "Tomo man-pages" +.SH NAME +List.counts \- Counts the occurrences of each element in the list. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.counts : func(list: [T] -> {T=Int})" +.fi + +.SH DESCRIPTION +Counts the occurrences of each element in the list. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The list to count elements in. - +.TE +.SH RETURN +A table mapping each element to its count. + +.SH EXAMPLES +.EX +>> [10, 20, 30, 30, 30].counts() += {10=1, 20=1, 30=3} +.EE diff --git a/man/man3/tomo-List.find.3 b/man/man3/tomo-List.find.3 new file mode 100644 index 00000000..d1b29f38 --- /dev/null +++ b/man/man3/tomo-List.find.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.find 3 2025-04-19T14:30:40.361070 "Tomo man-pages" +.SH NAME +List.find \- Finds the index of the first occurrence of an element (if any). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.find : func(list: [T], target: T -> Int?)" +.fi + +.SH DESCRIPTION +Finds the index of the first occurrence of an element (if any). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The list to search through. - +target T The item to search for. - +.TE +.SH RETURN +The index of the first occurrence or `!Int` if not found. + +.SH EXAMPLES +.EX +>> [10, 20, 30, 40, 50].find(20) += 2 : Int? + +>> [10, 20, 30, 40, 50].find(9999) += none : Int? +.EE diff --git a/man/man3/tomo-List.first.3 b/man/man3/tomo-List.first.3 new file mode 100644 index 00000000..4bde4a21 --- /dev/null +++ b/man/man3/tomo-List.first.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.first 3 2025-04-19T14:30:40.361125 "Tomo man-pages" +.SH NAME +List.first \- Find the index of the first item that matches a predicate function (if any). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.first : func(list: [T], predicate: func(item:&T -> Bool) -> Int)" +.fi + +.SH DESCRIPTION +Find the index of the first item that matches a predicate function (if any). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The list to search through. - +predicate func(item:&T -> Bool) A function that returns `yes` if the item should be returned or `no` if it should not. - +.TE +.SH RETURN +Returns the index of the first item where the predicate is true or `!Int` if no item matches. + +.SH EXAMPLES +.EX +>> [4, 5, 6].find(func(i:&Int): i.is_prime()) += 5 : Int? +>> [4, 6, 8].find(func(i:&Int): i.is_prime()) += none : Int? +.EE diff --git a/man/man3/tomo-List.from.3 b/man/man3/tomo-List.from.3 new file mode 100644 index 00000000..0ee5faa4 --- /dev/null +++ b/man/man3/tomo-List.from.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.from 3 2025-04-19T14:30:40.361167 "Tomo man-pages" +.SH NAME +List.from \- Returns a slice of the list starting from a specified index. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.from : func(list: [T], first: Int -> [T])" +.fi + +.SH DESCRIPTION +Returns a slice of the list starting from a specified index. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The original list. - +first Int The index to start from. - +.TE +.SH RETURN +A new list starting from the specified index. + +.SH EXAMPLES +.EX +>> [10, 20, 30, 40, 50].from(3) += [30, 40, 50] +.EE diff --git a/man/man3/tomo-List.has.3 b/man/man3/tomo-List.has.3 new file mode 100644 index 00000000..694a3b6f --- /dev/null +++ b/man/man3/tomo-List.has.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.has 3 2025-04-19T14:30:40.361206 "Tomo man-pages" +.SH NAME +List.has \- Checks if the list has an element. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.has : func(list: [T], target: T -> Bool)" +.fi + +.SH DESCRIPTION +Checks if the list has an element. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The list to check. - +target T The element to check for. - +.TE +.SH RETURN +`yes` if the list has the element, `no` otherwise. + +.SH EXAMPLES +.EX +>> [10, 20, 30].has(20) += yes +.EE diff --git a/man/man3/tomo-List.heap_pop.3 b/man/man3/tomo-List.heap_pop.3 new file mode 100644 index 00000000..f0cce34d --- /dev/null +++ b/man/man3/tomo-List.heap_pop.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.heap_pop 3 2025-04-19T14:30:40.361244 "Tomo man-pages" +.SH NAME +List.heap_pop \- Removes and returns the top element of a heap or `none` if the list is empty. By default, this is the *minimum* value in the heap. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.heap_pop : func(list: @[T], by: func(x,y:&T->Int32) = T.compare -> T?)" +.fi + +.SH DESCRIPTION +Removes and returns the top element of a heap or `none` if the list is empty. By default, this is the *minimum* value in the heap. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list @[T] The mutable reference to the heap. - +by func(x,y:&T->Int32) The comparison function used to determine order. If not specified, the default comparison function for the item type will be used. T.compare +.TE +.SH RETURN +The removed top element of the heap or `none` if the list is empty. + +.SH EXAMPLES +.EX +>> my_heap := [30, 10, 20] +>> my_heap.heapify() +>> my_heap.heap_pop() += 10 +.EE diff --git a/man/man3/tomo-List.heap_push.3 b/man/man3/tomo-List.heap_push.3 new file mode 100644 index 00000000..1de173c2 --- /dev/null +++ b/man/man3/tomo-List.heap_push.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.heap_push 3 2025-04-19T14:30:40.361282 "Tomo man-pages" +.SH NAME +List.heap_push \- Adds an element to the heap and maintains the heap property. By default, this is a *minimum* heap. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.heap_push : func(list: @[T], item: T, by = T.compare -> Void)" +.fi + +.SH DESCRIPTION +Adds an element to the heap and maintains the heap property. By default, this is a *minimum* heap. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list @[T] The mutable reference to the heap. - +item T The item to be added. - +by The comparison function used to determine order. If not specified, the default comparison function for the item type will be used. T.compare +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +>> my_heap.heap_push(10) +.EE diff --git a/man/man3/tomo-List.heapify.3 b/man/man3/tomo-List.heapify.3 new file mode 100644 index 00000000..f2df2674 --- /dev/null +++ b/man/man3/tomo-List.heapify.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.heapify 3 2025-04-19T14:30:40.361322 "Tomo man-pages" +.SH NAME +List.heapify \- Converts a list into a heap. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.heapify : func(list: @[T], by: func(x,y:&T->Int32) = T.compare -> Void)" +.fi + +.SH DESCRIPTION +Converts a list into a heap. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list @[T] The mutable reference to the list to be heapified. - +by func(x,y:&T->Int32) The comparison function used to determine order. If not specified, the default comparison function for the item type will be used. T.compare +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +>> my_heap := [30, 10, 20] +>> my_heap.heapify() +.EE diff --git a/man/man3/tomo-List.insert.3 b/man/man3/tomo-List.insert.3 new file mode 100644 index 00000000..dff1783d --- /dev/null +++ b/man/man3/tomo-List.insert.3 @@ -0,0 +1,45 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.insert 3 2025-04-19T14:30:40.361359 "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 diff --git a/man/man3/tomo-List.insert_all.3 b/man/man3/tomo-List.insert_all.3 new file mode 100644 index 00000000..9f7289d4 --- /dev/null +++ b/man/man3/tomo-List.insert_all.3 @@ -0,0 +1,45 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.insert_all 3 2025-04-19T14:30:40.361398 "Tomo man-pages" +.SH NAME +List.insert_all \- Inserts a list of items at a specified position in the list. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.insert_all : func(list: @[T], items: [T], at: Int = 0 -> Void)" +.fi + +.SH DESCRIPTION +Inserts a list of items 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. - +items [T] The items 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_all([30, 40]) +>> list += [10, 20, 30, 40] + +list.insert_all([99, 100], at=2) +>> list += [10, 99, 100, 20, 30, 40] +.EE diff --git a/man/man3/tomo-List.pop.3 b/man/man3/tomo-List.pop.3 new file mode 100644 index 00000000..303ae439 --- /dev/null +++ b/man/man3/tomo-List.pop.3 @@ -0,0 +1,47 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.pop 3 2025-04-19T14:30:40.361436 "Tomo man-pages" +.SH NAME +List.pop \- Removes and returns an item from the list. If the given index is present in the list, the item at that index will be removed and the list will become one element shorter. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.pop : func(list: &[T], index: Int = -1 -> T?)" +.fi + +.SH DESCRIPTION +Removes and returns an item from the list. If the given index is present in the list, the item at that index will be removed and the list will become one element shorter. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list &[T] The list to remove an item from. - +index Int The index from which to remove the item. -1 +.TE +.SH RETURN +`none` if the list is empty or the given index does not exist in the list, otherwise the item at the given index. + +.SH NOTES +Since negative indices are counted from the back, the default behavior is to pop the last value. + +.SH EXAMPLES +.EX +>> list := [10, 20, 30, 40] + +>> list.pop() += 40 +>> list += &[10, 20, 30] + +>> list.pop(index=2) += 20 +>> list += &[10, 30] +.EE diff --git a/man/man3/tomo-List.random.3 b/man/man3/tomo-List.random.3 new file mode 100644 index 00000000..65355a73 --- /dev/null +++ b/man/man3/tomo-List.random.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.random 3 2025-04-19T14:30:40.361484 "Tomo man-pages" +.SH NAME +List.random \- Selects a random element from the list. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.random : func(list: [T], random: func(min,max:Int64->Int64)? = none -> T)" +.fi + +.SH DESCRIPTION +Selects a random element from the list. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The list from which to select a random element. - +random func(min,max:Int64->Int64)? If provided, this function will be used to get a random index in the list. Returned values must be between `min` and `max` (inclusive). (Used for deterministic pseudorandom number generation) none +.TE +.SH RETURN +A random element from the list. + +.SH EXAMPLES +.EX +>> [10, 20, 30].random() += 20 +.EE diff --git a/man/man3/tomo-List.remove_at.3 b/man/man3/tomo-List.remove_at.3 new file mode 100644 index 00000000..241315a4 --- /dev/null +++ b/man/man3/tomo-List.remove_at.3 @@ -0,0 +1,45 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.remove_at 3 2025-04-19T14:30:40.361523 "Tomo man-pages" +.SH NAME +List.remove_at \- Removes elements from the list starting at a specified index. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.remove_at : func(list: @[T], at: Int = -1, count: Int = 1 -> Void)" +.fi + +.SH DESCRIPTION +Removes elements from the list starting at a specified index. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list @[T] The mutable reference to the list. - +at Int The index at which to start removing elements. -1 +count Int The number of elements to remove. 1 +.TE +.SH RETURN +Nothing. + +.SH NOTES +Since negative indices are counted from the back, the default behavior is to remove the last item. + +.SH EXAMPLES +.EX +list := [10, 20, 30, 40, 50] +list.remove_at(2) +>> list += [10, 30, 40, 50] + +list.remove_at(2, count=2) +>> list += [10, 50] +.EE diff --git a/man/man3/tomo-List.remove_item.3 b/man/man3/tomo-List.remove_item.3 new file mode 100644 index 00000000..5c4a2b32 --- /dev/null +++ b/man/man3/tomo-List.remove_item.3 @@ -0,0 +1,45 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.remove_item 3 2025-04-19T14:30:40.361566 "Tomo man-pages" +.SH NAME +List.remove_item \- Removes all occurrences of a specified item from the list. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.remove_item : func(list: @[T], item: T, max_count: Int = -1 -> Void)" +.fi + +.SH DESCRIPTION +Removes all occurrences of a specified item from 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 removed. - +max_count Int The maximum number of occurrences to remove. -1 +.TE +.SH RETURN +Nothing. + +.SH NOTES +A negative `max_count` means "remove all occurrences". + +.SH EXAMPLES +.EX +list := [10, 20, 10, 20, 30] +list.remove_item(10) +>> list += [20, 20, 30] + +list.remove_item(20, max_count=1) +>> list += [20, 30] +.EE diff --git a/man/man3/tomo-List.reversed.3 b/man/man3/tomo-List.reversed.3 new file mode 100644 index 00000000..dd0b2242 --- /dev/null +++ b/man/man3/tomo-List.reversed.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.reversed 3 2025-04-19T14:30:40.361612 "Tomo man-pages" +.SH NAME +List.reversed \- Returns a reversed slice of the list. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.reversed : func(list: [T] -> [T])" +.fi + +.SH DESCRIPTION +Returns a reversed slice of the list. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The list to be reversed. - +.TE +.SH RETURN +A slice of the list with elements in reverse order. + +.SH EXAMPLES +.EX +>> [10, 20, 30].reversed() += [30, 20, 10] +.EE diff --git a/man/man3/tomo-List.sample.3 b/man/man3/tomo-List.sample.3 new file mode 100644 index 00000000..a1142e95 --- /dev/null +++ b/man/man3/tomo-List.sample.3 @@ -0,0 +1,40 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.sample 3 2025-04-19T14:30:40.361676 "Tomo man-pages" +.SH NAME +List.sample \- Selects a sample of elements from the list, optionally with weighted probabilities. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.sample : func(list: [T], count: Int, weights: [Num]? = ![Num], random: func(->Num)? = none -> [T])" +.fi + +.SH DESCRIPTION +Selects a sample of elements from the list, optionally with weighted probabilities. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The list to sample from. - +count Int The number of elements to sample. - +weights [Num]? The probability weights for each element in the list. These values do not need to add up to any particular number, they are relative weights. If no weights are given, elements will be sampled with uniform probability. ![Num] +random func(->Num)? If provided, this function will be used to get random values for sampling the list. The provided function should return random numbers between `0.0` (inclusive) and `1.0` (exclusive). (Used for deterministic pseudorandom number generation) none +.TE +.SH RETURN +A list of sampled elements from the list. + +.SH ERRORS +Errors will be raised if any of the following conditions occurs: - The given list has no elements and `count >= 1` - `count < 0` (negative count) - The number of weights provided doesn't match the length of the list. - Any weight in the weights list is negative, infinite, or `NaN` - The sum of the given weights is zero (zero probability for every element). + +.SH EXAMPLES +.EX +>> [10, 20, 30].sample(2, weights=[90%, 5%, 5%]) += [10, 10] +.EE diff --git a/man/man3/tomo-List.shuffle.3 b/man/man3/tomo-List.shuffle.3 new file mode 100644 index 00000000..f6bf6dc4 --- /dev/null +++ b/man/man3/tomo-List.shuffle.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.shuffle 3 2025-04-19T14:30:40.361726 "Tomo man-pages" +.SH NAME +List.shuffle \- Shuffles the elements of the list in place. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.shuffle : func(list: @[T], random: func(min,max:Int64->Int64)? = none -> Void)" +.fi + +.SH DESCRIPTION +Shuffles the elements of the list in place. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list @[T] The mutable reference to the list to be shuffled. - +random func(min,max:Int64->Int64)? If provided, this function will be used to get a random index in the list. Returned values must be between `min` and `max` (inclusive). (Used for deterministic pseudorandom number generation) none +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +>> list.shuffle() +.EE diff --git a/man/man3/tomo-List.shuffled.3 b/man/man3/tomo-List.shuffled.3 new file mode 100644 index 00000000..7f62ace8 --- /dev/null +++ b/man/man3/tomo-List.shuffled.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.shuffled 3 2025-04-19T14:30:40.361789 "Tomo man-pages" +.SH NAME +List.shuffled \- Creates a new list with elements shuffled. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.shuffled : func(list: [T], random: func(min,max:Int64->Int64)? = none -> [T])" +.fi + +.SH DESCRIPTION +Creates a new list with elements shuffled. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The list to be shuffled. - +random func(min,max:Int64->Int64)? If provided, this function will be used to get a random index in the list. Returned values must be between `min` and `max` (inclusive). (Used for deterministic pseudorandom number generation) none +.TE +.SH RETURN +A new list with shuffled elements. + +.SH EXAMPLES +.EX +>> [10, 20, 30, 40].shuffled() += [40, 10, 30, 20] +.EE diff --git a/man/man3/tomo-List.slice.3 b/man/man3/tomo-List.slice.3 new file mode 100644 index 00000000..8cd76a8d --- /dev/null +++ b/man/man3/tomo-List.slice.3 @@ -0,0 +1,39 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.slice 3 2025-04-19T14:30:40.361827 "Tomo man-pages" +.SH NAME +List.slice \- Returns a slice of the list spanning the given indices (inclusive). + +.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). + + +.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 diff --git a/man/man3/tomo-List.sort.3 b/man/man3/tomo-List.sort.3 new file mode 100644 index 00000000..f8dac2a1 --- /dev/null +++ b/man/man3/tomo-List.sort.3 @@ -0,0 +1,41 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.sort 3 2025-04-19T14:30:40.361865 "Tomo man-pages" +.SH NAME +List.sort \- Sorts the elements of the list in place in ascending order (small to large). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.sort : func(list: @[T], by = T.compare -> Void)" +.fi + +.SH DESCRIPTION +Sorts the elements of the list in place in ascending order (small to large). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list @[T] The mutable reference to the list to be sorted. - +by The comparison function used to determine order. If not specified, the default comparison function for the item type will be used. T.compare +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +list := [40, 10, -30, 20] +list.sort() +>> list += [-30, 10, 20, 40] + +list.sort(func(a,b:&Int): a.abs() <> b.abs()) +>> list += [10, 20, -30, 40] +.EE diff --git a/man/man3/tomo-List.sorted.3 b/man/man3/tomo-List.sorted.3 new file mode 100644 index 00000000..05043cdc --- /dev/null +++ b/man/man3/tomo-List.sorted.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.sorted 3 2025-04-19T14:30:40.361919 "Tomo man-pages" +.SH NAME +List.sorted \- Creates a new list with elements sorted. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.sorted : func(list: [T], by = T.compare -> [T])" +.fi + +.SH DESCRIPTION +Creates a new list with elements sorted. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The list to be sorted. - +by The comparison function used to determine order. If not specified, the default comparison function for the item type will be used. T.compare +.TE +.SH RETURN +A new list with sorted elements. + +.SH EXAMPLES +.EX +>> [40, 10, -30, 20].sorted() += [-30, 10, 20, 40] + +>> [40, 10, -30, 20].sorted(func(a,b:&Int): a.abs() <> b.abs()) += [10, 20, -30, 40] +.EE diff --git a/man/man3/tomo-List.to.3 b/man/man3/tomo-List.to.3 new file mode 100644 index 00000000..82143c0b --- /dev/null +++ b/man/man3/tomo-List.to.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.to 3 2025-04-19T14:30:40.361956 "Tomo man-pages" +.SH NAME +List.to \- Returns a slice of the list from the start of the original list up to a specified index (inclusive). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.to : func(list: [T], last: Int -> [T])" +.fi + +.SH DESCRIPTION +Returns a slice of the list from the start of the original list up to a specified index (inclusive). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The original list. - +last Int The index up to which elements should be included. - +.TE +.SH RETURN +A new list containing elements from the start up to the specified index. + +.SH EXAMPLES +.EX +>> [10, 20, 30, 40, 50].to(3) += [10, 20, 30] + +>> [10, 20, 30, 40, 50].to(-2) += [10, 20, 30, 40] +.EE diff --git a/man/man3/tomo-List.unique.3 b/man/man3/tomo-List.unique.3 new file mode 100644 index 00000000..5beefe40 --- /dev/null +++ b/man/man3/tomo-List.unique.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH List.unique 3 2025-04-19T14:30:40.361993 "Tomo man-pages" +.SH NAME +List.unique \- Returns a Set that contains the unique elements of the list. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "List.unique : func(list: [T] -> |T|)" +.fi + +.SH DESCRIPTION +Returns a Set that contains the unique elements of the list. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +list [T] The list to process. - +.TE +.SH RETURN +A set containing only unique elements from the list. + +.SH EXAMPLES +.EX +>> [10, 20, 10, 10, 30].unique() += {10, 20, 30} +.EE diff --git a/man/man3/tomo-Num.1_PI.3 b/man/man3/tomo-Num.1_PI.3 new file mode 100644 index 00000000..3be0c785 --- /dev/null +++ b/man/man3/tomo-Num.1_PI.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.1_PI 3 2025-04-19T14:30:40.364254 "Tomo man-pages" +.SH NAME +Num.1_PI \- The constant $\frac{1}{\pi}$. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.1_PI : Num' +.fi + +.SH DESCRIPTION +The constant $\frac{1}{\pi}$. + diff --git a/man/man3/tomo-Num.2_PI.3 b/man/man3/tomo-Num.2_PI.3 new file mode 100644 index 00000000..688bec38 --- /dev/null +++ b/man/man3/tomo-Num.2_PI.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.2_PI 3 2025-04-19T14:30:40.364287 "Tomo man-pages" +.SH NAME +Num.2_PI \- The constant $2 \times \pi$. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.2_PI : Num' +.fi + +.SH DESCRIPTION +The constant $2 \times \pi$. + diff --git a/man/man3/tomo-Num.2_SQRTPI.3 b/man/man3/tomo-Num.2_SQRTPI.3 new file mode 100644 index 00000000..42470e67 --- /dev/null +++ b/man/man3/tomo-Num.2_SQRTPI.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.2_SQRTPI 3 2025-04-19T14:30:40.364319 "Tomo man-pages" +.SH NAME +Num.2_SQRTPI \- The constant $2 \times \sqrt{\pi}$. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.2_SQRTPI : Num' +.fi + +.SH DESCRIPTION +The constant $2 \times \sqrt{\pi}$. + diff --git a/man/man3/tomo-Num.E.3 b/man/man3/tomo-Num.E.3 new file mode 100644 index 00000000..9ee849aa --- /dev/null +++ b/man/man3/tomo-Num.E.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.E 3 2025-04-19T14:30:40.364352 "Tomo man-pages" +.SH NAME +Num.E \- The base of the natural logarithm ($e$). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.E : Num' +.fi + +.SH DESCRIPTION +The base of the natural logarithm ($e$). + diff --git a/man/man3/tomo-Num.INF.3 b/man/man3/tomo-Num.INF.3 new file mode 100644 index 00000000..51520ce9 --- /dev/null +++ b/man/man3/tomo-Num.INF.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.INF 3 2025-04-19T14:30:40.364384 "Tomo man-pages" +.SH NAME +Num.INF \- Positive infinity. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.INF : Num' +.fi + +.SH DESCRIPTION +Positive infinity. + diff --git a/man/man3/tomo-Num.LN10.3 b/man/man3/tomo-Num.LN10.3 new file mode 100644 index 00000000..9905d365 --- /dev/null +++ b/man/man3/tomo-Num.LN10.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.LN10 3 2025-04-19T14:30:40.364415 "Tomo man-pages" +.SH NAME +Num.LN10 \- The natural logarithm of 10. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.LN10 : Num' +.fi + +.SH DESCRIPTION +The natural logarithm of 10. + diff --git a/man/man3/tomo-Num.LN2.3 b/man/man3/tomo-Num.LN2.3 new file mode 100644 index 00000000..e4963292 --- /dev/null +++ b/man/man3/tomo-Num.LN2.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.LN2 3 2025-04-19T14:30:40.364450 "Tomo man-pages" +.SH NAME +Num.LN2 \- The natural logarithm of 2. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.LN2 : Num' +.fi + +.SH DESCRIPTION +The natural logarithm of 2. + diff --git a/man/man3/tomo-Num.LOG2E.3 b/man/man3/tomo-Num.LOG2E.3 new file mode 100644 index 00000000..85cebf47 --- /dev/null +++ b/man/man3/tomo-Num.LOG2E.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.LOG2E 3 2025-04-19T14:30:40.364491 "Tomo man-pages" +.SH NAME +Num.LOG2E \- The base 2 logarithm of $e$ + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.LOG2E : Num' +.fi + +.SH DESCRIPTION +The base 2 logarithm of $e$ + diff --git a/man/man3/tomo-Num.PI.3 b/man/man3/tomo-Num.PI.3 new file mode 100644 index 00000000..2ed8035b --- /dev/null +++ b/man/man3/tomo-Num.PI.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.PI 3 2025-04-19T14:30:40.364524 "Tomo man-pages" +.SH NAME +Num.PI \- Pi ($\pi$). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.PI : Num' +.fi + +.SH DESCRIPTION +Pi ($\pi$). + diff --git a/man/man3/tomo-Num.PI_2.3 b/man/man3/tomo-Num.PI_2.3 new file mode 100644 index 00000000..207d14ca --- /dev/null +++ b/man/man3/tomo-Num.PI_2.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.PI_2 3 2025-04-19T14:30:40.364557 "Tomo man-pages" +.SH NAME +Num.PI_2 \- $\frac{\pi}{2}$ + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.PI_2 : Num' +.fi + +.SH DESCRIPTION +$\frac{\pi}{2}$ + diff --git a/man/man3/tomo-Num.PI_4.3 b/man/man3/tomo-Num.PI_4.3 new file mode 100644 index 00000000..a98c455b --- /dev/null +++ b/man/man3/tomo-Num.PI_4.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.PI_4 3 2025-04-19T14:30:40.364588 "Tomo man-pages" +.SH NAME +Num.PI_4 \- $\frac{\pi}{4}$ + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.PI_4 : Num' +.fi + +.SH DESCRIPTION +$\frac{\pi}{4}$ + diff --git a/man/man3/tomo-Num.SQRT1_2.3 b/man/man3/tomo-Num.SQRT1_2.3 new file mode 100644 index 00000000..4ddfc6e0 --- /dev/null +++ b/man/man3/tomo-Num.SQRT1_2.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.SQRT1_2 3 2025-04-19T14:30:40.364618 "Tomo man-pages" +.SH NAME +Num.SQRT1_2 \- $\sqrt{\frac{1}{2}}$ + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.SQRT1_2 : Num' +.fi + +.SH DESCRIPTION +$\sqrt{\frac{1}{2}}$ + diff --git a/man/man3/tomo-Num.SQRT2.3 b/man/man3/tomo-Num.SQRT2.3 new file mode 100644 index 00000000..21c62073 --- /dev/null +++ b/man/man3/tomo-Num.SQRT2.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.SQRT2 3 2025-04-19T14:30:40.364647 "Tomo man-pages" +.SH NAME +Num.SQRT2 \- $\sqrt{2}$ + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.SQRT2 : Num' +.fi + +.SH DESCRIPTION +$\sqrt{2}$ + diff --git a/man/man3/tomo-Num.TAU.3 b/man/man3/tomo-Num.TAU.3 new file mode 100644 index 00000000..d22a5e99 --- /dev/null +++ b/man/man3/tomo-Num.TAU.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.TAU 3 2025-04-19T14:30:40.364676 "Tomo man-pages" +.SH NAME +Num.TAU \- Tau ($2 \times \pi$) + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'Num.TAU : Num' +.fi + +.SH DESCRIPTION +Tau ($2 \times \pi$) + diff --git a/man/man3/tomo-Num.abs.3 b/man/man3/tomo-Num.abs.3 new file mode 100644 index 00000000..fa438fd4 --- /dev/null +++ b/man/man3/tomo-Num.abs.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.abs 3 2025-04-19T14:30:40.362029 "Tomo man-pages" +.SH NAME +Num.abs \- Calculates the absolute value of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.abs : func(n: Num -> Num)" +.fi + +.SH DESCRIPTION +Calculates the absolute value of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +n Num The number whose absolute value is to be computed. - +.TE +.SH RETURN +The absolute value of `n`. + +.SH EXAMPLES +.EX +>> (-3.5).abs() += 3.5 +.EE diff --git a/man/man3/tomo-Num.acos.3 b/man/man3/tomo-Num.acos.3 new file mode 100644 index 00000000..74ed1f90 --- /dev/null +++ b/man/man3/tomo-Num.acos.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.acos 3 2025-04-19T14:30:40.362066 "Tomo man-pages" +.SH NAME +Num.acos \- Computes the arc cosine of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.acos : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the arc cosine of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the arc cosine is to be calculated. - +.TE +.SH RETURN +The arc cosine of `x` in radians. + +.SH EXAMPLES +.EX +>> (0.0).acos() // -> (π/2) += 1.5708 +.EE diff --git a/man/man3/tomo-Num.acosh.3 b/man/man3/tomo-Num.acosh.3 new file mode 100644 index 00000000..13eea6ed --- /dev/null +++ b/man/man3/tomo-Num.acosh.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.acosh 3 2025-04-19T14:30:40.362105 "Tomo man-pages" +.SH NAME +Num.acosh \- Computes the inverse hyperbolic cosine of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.acosh : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the inverse hyperbolic cosine of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the inverse hyperbolic cosine is to be calculated. - +.TE +.SH RETURN +The inverse hyperbolic cosine of `x`. + +.SH EXAMPLES +.EX +>> (1.0).acosh() += 0 +.EE diff --git a/man/man3/tomo-Num.asin.3 b/man/man3/tomo-Num.asin.3 new file mode 100644 index 00000000..76fbc1fd --- /dev/null +++ b/man/man3/tomo-Num.asin.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.asin 3 2025-04-19T14:30:40.362141 "Tomo man-pages" +.SH NAME +Num.asin \- Computes the arc sine of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.asin : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the arc sine of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the arc sine is to be calculated. - +.TE +.SH RETURN +The arc sine of `x` in radians. + +.SH EXAMPLES +.EX +>> (0.5).asin() // -> (π/6) += 0.5236 +.EE diff --git a/man/man3/tomo-Num.asinh.3 b/man/man3/tomo-Num.asinh.3 new file mode 100644 index 00000000..06fcd4a5 --- /dev/null +++ b/man/man3/tomo-Num.asinh.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.asinh 3 2025-04-19T14:30:40.362177 "Tomo man-pages" +.SH NAME +Num.asinh \- Computes the inverse hyperbolic sine of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.asinh : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the inverse hyperbolic sine of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the inverse hyperbolic sine is to be calculated. - +.TE +.SH RETURN +The inverse hyperbolic sine of `x`. + +.SH EXAMPLES +.EX +>> (0.0).asinh() += 0 +.EE diff --git a/man/man3/tomo-Num.atan.3 b/man/man3/tomo-Num.atan.3 new file mode 100644 index 00000000..ca041ba2 --- /dev/null +++ b/man/man3/tomo-Num.atan.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.atan 3 2025-04-19T14:30:40.362211 "Tomo man-pages" +.SH NAME +Num.atan \- Computes the arc tangent of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.atan : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the arc tangent of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the arc tangent is to be calculated. - +.TE +.SH RETURN +The arc tangent of `x` in radians. + +.SH EXAMPLES +.EX +>> (1.0).atan() // -> (π/4) += 0.7854 +.EE diff --git a/man/man3/tomo-Num.atan2.3 b/man/man3/tomo-Num.atan2.3 new file mode 100644 index 00000000..25423767 --- /dev/null +++ b/man/man3/tomo-Num.atan2.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.atan2 3 2025-04-19T14:30:40.362246 "Tomo man-pages" +.SH NAME +Num.atan2 \- Computes the arc tangent of the quotient of two numbers. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.atan2 : func(x: Num, y: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the arc tangent of the quotient of two numbers. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The numerator. - +y Num The denominator. - +.TE +.SH RETURN +The arc tangent of `x/y` in radians. + +.SH EXAMPLES +.EX +>> Num.atan2(1, 1) // -> (π/4) += 0.7854 +.EE diff --git a/man/man3/tomo-Num.atanh.3 b/man/man3/tomo-Num.atanh.3 new file mode 100644 index 00000000..7618a3ae --- /dev/null +++ b/man/man3/tomo-Num.atanh.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.atanh 3 2025-04-19T14:30:40.362303 "Tomo man-pages" +.SH NAME +Num.atanh \- Computes the inverse hyperbolic tangent of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.atanh : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the inverse hyperbolic tangent of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the inverse hyperbolic tangent is to be calculated. - +.TE +.SH RETURN +The inverse hyperbolic tangent of `x`. + +.SH EXAMPLES +.EX +>> (0.5).atanh() += 0.5493 +.EE diff --git a/man/man3/tomo-Num.cbrt.3 b/man/man3/tomo-Num.cbrt.3 new file mode 100644 index 00000000..91d5b975 --- /dev/null +++ b/man/man3/tomo-Num.cbrt.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.cbrt 3 2025-04-19T14:30:40.362342 "Tomo man-pages" +.SH NAME +Num.cbrt \- Computes the cube root of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.cbrt : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the cube root of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the cube root is to be calculated. - +.TE +.SH RETURN +The cube root of `x`. + +.SH EXAMPLES +.EX +>> (27.0).cbrt() += 3 +.EE diff --git a/man/man3/tomo-Num.ceil.3 b/man/man3/tomo-Num.ceil.3 new file mode 100644 index 00000000..ee5abc83 --- /dev/null +++ b/man/man3/tomo-Num.ceil.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.ceil 3 2025-04-19T14:30:40.362380 "Tomo man-pages" +.SH NAME +Num.ceil \- Rounds a number up to the nearest integer. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.ceil : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Rounds a number up to the nearest integer. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number to be rounded up. - +.TE +.SH RETURN +The smallest integer greater than or equal to `x`. + +.SH EXAMPLES +.EX +>> (3.2).ceil() += 4 +.EE diff --git a/man/man3/tomo-Num.clamped.3 b/man/man3/tomo-Num.clamped.3 new file mode 100644 index 00000000..36eefe7f --- /dev/null +++ b/man/man3/tomo-Num.clamped.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.clamped 3 2025-04-19T14:30:40.362416 "Tomo man-pages" +.SH NAME +Num.clamped \- Returns the given number clamped between two values so that it is within that range. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.clamped : func(x: Num, low: Num, high: Num -> Num)" +.fi + +.SH DESCRIPTION +Returns the given number clamped between two values so that it is within that range. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number to clamp. - +low Num The lowest value the result can take. - +high Num The highest value the result can take. - +.TE +.SH RETURN +The first argument clamped between the other two arguments. + +.SH EXAMPLES +.EX +>> (2.5).clamped(5.5, 10.5) += 5.5 +.EE diff --git a/man/man3/tomo-Num.copysign.3 b/man/man3/tomo-Num.copysign.3 new file mode 100644 index 00000000..b20194b1 --- /dev/null +++ b/man/man3/tomo-Num.copysign.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.copysign 3 2025-04-19T14:30:40.362460 "Tomo man-pages" +.SH NAME +Num.copysign \- Copies the sign of one number to another. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.copysign : func(x: Num, y: Num -> Num)" +.fi + +.SH DESCRIPTION +Copies the sign of one number to another. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number whose magnitude will be copied. - +y Num The number whose sign will be copied. - +.TE +.SH RETURN +A number with the magnitude of `x` and the sign of `y`. + +.SH EXAMPLES +.EX +>> (3.0).copysign(-1) += -3 +.EE diff --git a/man/man3/tomo-Num.cos.3 b/man/man3/tomo-Num.cos.3 new file mode 100644 index 00000000..4da01be3 --- /dev/null +++ b/man/man3/tomo-Num.cos.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.cos 3 2025-04-19T14:30:40.362505 "Tomo man-pages" +.SH NAME +Num.cos \- Computes the cosine of a number (angle in radians). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.cos : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the cosine of a number (angle in radians). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The angle in radians. - +.TE +.SH RETURN +The cosine of `x`. + +.SH EXAMPLES +.EX +>> (0.0).cos() += 1 +.EE diff --git a/man/man3/tomo-Num.cosh.3 b/man/man3/tomo-Num.cosh.3 new file mode 100644 index 00000000..577b2f08 --- /dev/null +++ b/man/man3/tomo-Num.cosh.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.cosh 3 2025-04-19T14:30:40.362548 "Tomo man-pages" +.SH NAME +Num.cosh \- Computes the hyperbolic cosine of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.cosh : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the hyperbolic cosine of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the hyperbolic cosine is to be calculated. - +.TE +.SH RETURN +The hyperbolic cosine of `x`. + +.SH EXAMPLES +.EX +>> (0.0).cosh() += 1 +.EE diff --git a/man/man3/tomo-Num.erf.3 b/man/man3/tomo-Num.erf.3 new file mode 100644 index 00000000..0ed7401d --- /dev/null +++ b/man/man3/tomo-Num.erf.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.erf 3 2025-04-19T14:30:40.362584 "Tomo man-pages" +.SH NAME +Num.erf \- Computes the error function of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.erf : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the error function of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the error function is to be calculated. - +.TE +.SH RETURN +The error function of `x`. + +.SH EXAMPLES +.EX +>> (0.0).erf() += 0 +.EE diff --git a/man/man3/tomo-Num.erfc.3 b/man/man3/tomo-Num.erfc.3 new file mode 100644 index 00000000..c392f051 --- /dev/null +++ b/man/man3/tomo-Num.erfc.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.erfc 3 2025-04-19T14:30:40.362619 "Tomo man-pages" +.SH NAME +Num.erfc \- Computes the complementary error function of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.erfc : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the complementary error function of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the complementary error function is to be calculated. - +.TE +.SH RETURN +The complementary error function of `x`. + +.SH EXAMPLES +.EX +>> (0.0).erfc() += 1 +.EE diff --git a/man/man3/tomo-Num.exp.3 b/man/man3/tomo-Num.exp.3 new file mode 100644 index 00000000..91de43a3 --- /dev/null +++ b/man/man3/tomo-Num.exp.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.exp 3 2025-04-19T14:30:40.362655 "Tomo man-pages" +.SH NAME +Num.exp \- Computes the exponential function $e^x$ for a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.exp : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the exponential function $e^x$ for a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The exponent. - +.TE +.SH RETURN +The value of $e^x$. + +.SH EXAMPLES +.EX +>> (1.0).exp() += 2.7183 +.EE diff --git a/man/man3/tomo-Num.exp2.3 b/man/man3/tomo-Num.exp2.3 new file mode 100644 index 00000000..ecebc8d0 --- /dev/null +++ b/man/man3/tomo-Num.exp2.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.exp2 3 2025-04-19T14:30:40.362690 "Tomo man-pages" +.SH NAME +Num.exp2 \- Computes $2^x$ for a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.exp2 : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes $2^x$ for a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The exponent. - +.TE +.SH RETURN +The value of $2^x$. + +.SH EXAMPLES +.EX +>> (3.0).exp2() += 8 +.EE diff --git a/man/man3/tomo-Num.expm1.3 b/man/man3/tomo-Num.expm1.3 new file mode 100644 index 00000000..617735e4 --- /dev/null +++ b/man/man3/tomo-Num.expm1.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.expm1 3 2025-04-19T14:30:40.362725 "Tomo man-pages" +.SH NAME +Num.expm1 \- Computes $e^x - 1$ for a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.expm1 : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes $e^x - 1$ for a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The exponent. - +.TE +.SH RETURN +The value of $e^x - 1$. + +.SH EXAMPLES +.EX +>> (1.0).expm1() += 1.7183 +.EE diff --git a/man/man3/tomo-Num.fdim.3 b/man/man3/tomo-Num.fdim.3 new file mode 100644 index 00000000..bd893aed --- /dev/null +++ b/man/man3/tomo-Num.fdim.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.fdim 3 2025-04-19T14:30:40.362760 "Tomo man-pages" +.SH NAME +Num.fdim \- Computes the positive difference between two numbers. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.fdim : func(x: Num, y: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the positive difference between two numbers. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The first number. - +y Num The second number. - +.TE +.SH RETURN +The positive difference $\max(0, x - y)$. + +.SH EXAMPLES +.EX +fd + +>> (5.0).fdim(3) += 2 +.EE diff --git a/man/man3/tomo-Num.floor.3 b/man/man3/tomo-Num.floor.3 new file mode 100644 index 00000000..8daffc44 --- /dev/null +++ b/man/man3/tomo-Num.floor.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.floor 3 2025-04-19T14:30:40.362796 "Tomo man-pages" +.SH NAME +Num.floor \- Rounds a number down to the nearest integer. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.floor : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Rounds a number down to the nearest integer. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number to be rounded down. - +.TE +.SH RETURN +The largest integer less than or equal to `x`. + +.SH EXAMPLES +.EX +>> (3.7).floor() += 3 +.EE diff --git a/man/man3/tomo-Num.format.3 b/man/man3/tomo-Num.format.3 new file mode 100644 index 00000000..eedd87a4 --- /dev/null +++ b/man/man3/tomo-Num.format.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.format 3 2025-04-19T14:30:40.362831 "Tomo man-pages" +.SH NAME +Num.format \- Formats a number as a text with a specified precision. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.format : func(n: Num, precision: Int = 0 -> Text)" +.fi + +.SH DESCRIPTION +Formats a number as a text with a specified precision. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +n Num The number to be formatted. - +precision Int The number of decimal places. Default is `0`. 0 +.TE +.SH RETURN +A text representation of the number with the specified precision. + +.SH EXAMPLES +.EX +>> (3.14159).format(precision=2) += "3.14" +.EE diff --git a/man/man3/tomo-Num.hypot.3 b/man/man3/tomo-Num.hypot.3 new file mode 100644 index 00000000..c38e05d7 --- /dev/null +++ b/man/man3/tomo-Num.hypot.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.hypot 3 2025-04-19T14:30:40.362867 "Tomo man-pages" +.SH NAME +Num.hypot \- Computes the Euclidean norm, $\sqrt{x^2 + y^2}$, of two numbers. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.hypot : func(x: Num, y: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the Euclidean norm, $\sqrt{x^2 + y^2}$, of two numbers. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The first number. - +y Num The second number. - +.TE +.SH RETURN +The Euclidean norm of `x` and `y`. + +.SH EXAMPLES +.EX +>> Num.hypot(3, 4) += 5 +.EE diff --git a/man/man3/tomo-Num.is_between.3 b/man/man3/tomo-Num.is_between.3 new file mode 100644 index 00000000..5b008cbb --- /dev/null +++ b/man/man3/tomo-Num.is_between.3 @@ -0,0 +1,40 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.is_between 3 2025-04-19T14:30:40.362934 "Tomo man-pages" +.SH NAME +Num.is_between \- Determines if a number is between two numbers (inclusive). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.is_between : func(x: Num, low: Num, high: Num -> Bool)" +.fi + +.SH DESCRIPTION +Determines if a number is between two numbers (inclusive). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The integer to be checked. - +low Num The lower bound to check (inclusive). - +high Num The upper bound to check (inclusive). - +.TE +.SH RETURN +`yes` if `low <= x and x <= high`, otherwise `no` + +.SH EXAMPLES +.EX +>> (7.5).is_between(1, 10) += yes +>> (7.5).is_between(100, 200) += no +>> (7.5).is_between(1, 7.5) += yes +.EE diff --git a/man/man3/tomo-Num.isfinite.3 b/man/man3/tomo-Num.isfinite.3 new file mode 100644 index 00000000..1e0f2b73 --- /dev/null +++ b/man/man3/tomo-Num.isfinite.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.isfinite 3 2025-04-19T14:30:40.362901 "Tomo man-pages" +.SH NAME +Num.isfinite \- Checks if a number is finite. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.isfinite : func(n: Num -> Bool)" +.fi + +.SH DESCRIPTION +Checks if a number is finite. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +n Num The number to be checked. - +.TE +.SH RETURN +`yes` if `n` is finite, `no` otherwise. + +.SH EXAMPLES +.EX +>> (1.0).isfinite() += yes +>> Num.INF.isfinite() += no +.EE diff --git a/man/man3/tomo-Num.isinf.3 b/man/man3/tomo-Num.isinf.3 new file mode 100644 index 00000000..225ad548 --- /dev/null +++ b/man/man3/tomo-Num.isinf.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.isinf 3 2025-04-19T14:30:40.363007 "Tomo man-pages" +.SH NAME +Num.isinf \- Checks if a number is infinite. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.isinf : func(n: Num -> Bool)" +.fi + +.SH DESCRIPTION +Checks if a number is infinite. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +n Num The number to be checked. - +.TE +.SH RETURN +`yes` if `n` is infinite, `no` otherwise. + +.SH EXAMPLES +.EX +>> Num.INF.isinf() += yes +>> (1.0).isinf() += no +.EE diff --git a/man/man3/tomo-Num.j0.3 b/man/man3/tomo-Num.j0.3 new file mode 100644 index 00000000..bef1a41b --- /dev/null +++ b/man/man3/tomo-Num.j0.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.j0 3 2025-04-19T14:30:40.363075 "Tomo man-pages" +.SH NAME +Num.j0 \- Computes the Bessel function of the first kind of order 0. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.j0 : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the Bessel function of the first kind of order 0. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the Bessel function is to be calculated. - +.TE +.SH RETURN +The Bessel function of the first kind of order 0 of `x`. + +.SH EXAMPLES +.EX +>> (0.0).j0() += 1 +.EE diff --git a/man/man3/tomo-Num.j1.3 b/man/man3/tomo-Num.j1.3 new file mode 100644 index 00000000..b1d09e8c --- /dev/null +++ b/man/man3/tomo-Num.j1.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.j1 3 2025-04-19T14:30:40.363115 "Tomo man-pages" +.SH NAME +Num.j1 \- Computes the Bessel function of the first kind of order 1. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.j1 : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the Bessel function of the first kind of order 1. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the Bessel function is to be calculated. - +.TE +.SH RETURN +The Bessel function of the first kind of order 1 of `x`. + +.SH EXAMPLES +.EX +>> (0.0).j1() += 0 +.EE diff --git a/man/man3/tomo-Num.log.3 b/man/man3/tomo-Num.log.3 new file mode 100644 index 00000000..322de2e6 --- /dev/null +++ b/man/man3/tomo-Num.log.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.log 3 2025-04-19T14:30:40.363156 "Tomo man-pages" +.SH NAME +Num.log \- Computes the natural logarithm (base $e$) of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.log : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the natural logarithm (base $e$) of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the natural logarithm is to be calculated. - +.TE +.SH RETURN +The natural logarithm of `x`. + +.SH EXAMPLES +.EX +>> Num.E.log() += 1 +.EE diff --git a/man/man3/tomo-Num.log10.3 b/man/man3/tomo-Num.log10.3 new file mode 100644 index 00000000..accf2234 --- /dev/null +++ b/man/man3/tomo-Num.log10.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.log10 3 2025-04-19T14:30:40.363192 "Tomo man-pages" +.SH NAME +Num.log10 \- Computes the base-10 logarithm of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.log10 : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the base-10 logarithm of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the base-10 logarithm is to be calculated. - +.TE +.SH RETURN +The base-10 logarithm of `x`. + +.SH EXAMPLES +.EX +>> (100.0).log10() += 2 +.EE diff --git a/man/man3/tomo-Num.log1p.3 b/man/man3/tomo-Num.log1p.3 new file mode 100644 index 00000000..0dcf77f2 --- /dev/null +++ b/man/man3/tomo-Num.log1p.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.log1p 3 2025-04-19T14:30:40.363229 "Tomo man-pages" +.SH NAME +Num.log1p \- Computes $\log(1 + x)$ for a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.log1p : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes $\log(1 + x)$ for a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which $\log(1 + x)$ is to be calculated. - +.TE +.SH RETURN +The value of $\log(1 + x)$. + +.SH EXAMPLES +.EX +>> (1.0).log1p() += 0.6931 +.EE diff --git a/man/man3/tomo-Num.log2.3 b/man/man3/tomo-Num.log2.3 new file mode 100644 index 00000000..fd40282d --- /dev/null +++ b/man/man3/tomo-Num.log2.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.log2 3 2025-04-19T14:30:40.363268 "Tomo man-pages" +.SH NAME +Num.log2 \- Computes the base-2 logarithm of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.log2 : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the base-2 logarithm of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the base-2 logarithm is to be calculated. - +.TE +.SH RETURN +The base-2 logarithm of `x`. + +.SH EXAMPLES +.EX +>> (8.0).log2() += 3 +.EE diff --git a/man/man3/tomo-Num.logb.3 b/man/man3/tomo-Num.logb.3 new file mode 100644 index 00000000..a13caa32 --- /dev/null +++ b/man/man3/tomo-Num.logb.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.logb 3 2025-04-19T14:30:40.363303 "Tomo man-pages" +.SH NAME +Num.logb \- Computes the binary exponent (base-2 logarithm) of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.logb : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the binary exponent (base-2 logarithm) of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the binary exponent is to be calculated. - +.TE +.SH RETURN +The binary exponent of `x`. + +.SH EXAMPLES +.EX +>> (8.0).logb() += 3 +.EE diff --git a/man/man3/tomo-Num.mix.3 b/man/man3/tomo-Num.mix.3 new file mode 100644 index 00000000..804f0746 --- /dev/null +++ b/man/man3/tomo-Num.mix.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.mix 3 2025-04-19T14:30:40.363337 "Tomo man-pages" +.SH NAME +Num.mix \- Interpolates between two numbers based on a given amount. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.mix : func(amount: Num, x: Num, y: Num -> Num)" +.fi + +.SH DESCRIPTION +Interpolates between two numbers based on a given amount. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +amount Num The interpolation factor (between `0` and `1`). - +x Num The starting number. - +y Num The ending number. - +.TE +.SH RETURN +The interpolated number between `x` and `y` based on `amount`. + +.SH EXAMPLES +.EX +>> (0.5).mix(10, 20) += 15 +>> (0.25).mix(10, 20) += 12.5 +.EE diff --git a/man/man3/tomo-Num.near.3 b/man/man3/tomo-Num.near.3 new file mode 100644 index 00000000..934e47cf --- /dev/null +++ b/man/man3/tomo-Num.near.3 @@ -0,0 +1,43 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.near 3 2025-04-19T14:30:40.363375 "Tomo man-pages" +.SH NAME +Num.near \- Checks if two numbers are approximately equal within specified tolerances. If two numbers are within an absolute difference or the ratio between the two is small enough, they are considered near each other. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.near : func(x: Num, y: Num, ratio: Num = 1e-9, min_epsilon: Num = 1e-9 -> Bool)" +.fi + +.SH DESCRIPTION +Checks if two numbers are approximately equal within specified tolerances. If two numbers are within an absolute difference or the ratio between the two is small enough, they are considered near each other. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The first number. - +y Num The second number. - +ratio Num The relative tolerance. Default is `1e-9`. 1e-9 +min_epsilon Num The absolute tolerance. Default is `1e-9`. 1e-9 +.TE +.SH RETURN +`yes` if `x` and `y` are approximately equal within the specified tolerances, `no` otherwise. + +.SH EXAMPLES +.EX +>> (1.0).near(1.000000001) += yes + +>> (100.0).near(110, ratio=0.1) += yes + +>> (5.0).near(5.1, min_epsilon=0.1) += yes +.EE diff --git a/man/man3/tomo-Num.nextafter.3 b/man/man3/tomo-Num.nextafter.3 new file mode 100644 index 00000000..c581e700 --- /dev/null +++ b/man/man3/tomo-Num.nextafter.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.nextafter 3 2025-04-19T14:30:40.363421 "Tomo man-pages" +.SH NAME +Num.nextafter \- Computes the next representable value after a given number towards a specified direction. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.nextafter : func(x: Num, y: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the next representable value after a given number towards a specified direction. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The starting number. - +y Num The direction towards which to find the next representable value. - +.TE +.SH RETURN +The next representable value after `x` in the direction of `y`. + +.SH EXAMPLES +.EX +>> (1.0).nextafter(1.1) += 1.0000000000000002 +.EE diff --git a/man/man3/tomo-Num.parse.3 b/man/man3/tomo-Num.parse.3 new file mode 100644 index 00000000..79211e96 --- /dev/null +++ b/man/man3/tomo-Num.parse.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.parse 3 2025-04-19T14:30:40.363458 "Tomo man-pages" +.SH NAME +Num.parse \- Converts a text representation of a number into a floating-point number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.parse : func(text: Text -> Num?)" +.fi + +.SH DESCRIPTION +Converts a text representation of a number into a floating-point number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text containing the number. - +.TE +.SH RETURN +The number represented by the text or `none` if the entire text can't be parsed as a number. + +.SH EXAMPLES +.EX +>> Num.parse("3.14") += 3.14 +>> Num.parse("1e3") += 1000 +.EE diff --git a/man/man3/tomo-Num.percent.3 b/man/man3/tomo-Num.percent.3 new file mode 100644 index 00000000..d85f86d0 --- /dev/null +++ b/man/man3/tomo-Num.percent.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.percent 3 2025-04-19T14:30:40.363501 "Tomo man-pages" +.SH NAME +Num.percent \- Convert a number into a percentage text with a percent sign. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.percent : func(n: Num, precision: Int = 0 -> Text)" +.fi + +.SH DESCRIPTION +Convert a number into a percentage text with a percent sign. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +n Num The number to be converted to a percent. - +precision Int The number of decimal places. Default is `0`. 0 +.TE +.SH RETURN +A text representation of the number as a percentage with a percent sign. + +.SH EXAMPLES +.EX +>> (0.5).percent() += "50%" +>> (1./3.).percent(2) += "33.33%" +.EE diff --git a/man/man3/tomo-Num.rint.3 b/man/man3/tomo-Num.rint.3 new file mode 100644 index 00000000..0cef35e2 --- /dev/null +++ b/man/man3/tomo-Num.rint.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.rint 3 2025-04-19T14:30:40.363539 "Tomo man-pages" +.SH NAME +Num.rint \- Rounds a number to the nearest integer, with ties rounded to the nearest even integer. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.rint : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Rounds a number to the nearest integer, with ties rounded to the nearest even integer. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number to be rounded. - +.TE +.SH RETURN +The nearest integer value of `x`. + +.SH EXAMPLES +.EX +>> (3.5).rint() += 4 +>> (2.5).rint() += 2 +.EE diff --git a/man/man3/tomo-Num.round.3 b/man/man3/tomo-Num.round.3 new file mode 100644 index 00000000..c951503a --- /dev/null +++ b/man/man3/tomo-Num.round.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.round 3 2025-04-19T14:30:40.363582 "Tomo man-pages" +.SH NAME +Num.round \- Rounds a number to the nearest whole number integer. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.round : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Rounds a number to the nearest whole number integer. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number to be rounded. - +.TE +.SH RETURN +The nearest integer value of `x`. + +.SH EXAMPLES +.EX +>> (2.3).round() += 2 +>> (2.7).round() += 3 +.EE diff --git a/man/man3/tomo-Num.scientific.3 b/man/man3/tomo-Num.scientific.3 new file mode 100644 index 00000000..e1db35a1 --- /dev/null +++ b/man/man3/tomo-Num.scientific.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.scientific 3 2025-04-19T14:30:40.363662 "Tomo man-pages" +.SH NAME +Num.scientific \- Formats a number in scientific notation with a specified precision. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.scientific : func(n: Num, precision: Int = 0 -> Text)" +.fi + +.SH DESCRIPTION +Formats a number in scientific notation with a specified precision. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +n Num The number to be formatted. - +precision Int The number of decimal places. Default is `0`. 0 +.TE +.SH RETURN +A text representation of the number in scientific notation with the specified precision. + +.SH EXAMPLES +.EX +>> (12345.6789).scientific(precision=2) += "1.23e+04" +.EE diff --git a/man/man3/tomo-Num.significand.3 b/man/man3/tomo-Num.significand.3 new file mode 100644 index 00000000..44f20d64 --- /dev/null +++ b/man/man3/tomo-Num.significand.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.significand 3 2025-04-19T14:30:40.363710 "Tomo man-pages" +.SH NAME +Num.significand \- Extracts the significand (or mantissa) of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.significand : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Extracts the significand (or mantissa) of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number from which to extract the significand. - +.TE +.SH RETURN +The significand of `x`. + +.SH EXAMPLES +.EX +>> (1234.567).significand() += 0.1234567 +.EE diff --git a/man/man3/tomo-Num.sin.3 b/man/man3/tomo-Num.sin.3 new file mode 100644 index 00000000..3781cdc4 --- /dev/null +++ b/man/man3/tomo-Num.sin.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.sin 3 2025-04-19T14:30:40.363772 "Tomo man-pages" +.SH NAME +Num.sin \- Computes the sine of a number (angle in radians). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.sin : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the sine of a number (angle in radians). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The angle in radians. - +.TE +.SH RETURN +The sine of `x`. + +.SH EXAMPLES +.EX +>> (0.0).sin() += 0 +.EE diff --git a/man/man3/tomo-Num.sinh.3 b/man/man3/tomo-Num.sinh.3 new file mode 100644 index 00000000..00cf9442 --- /dev/null +++ b/man/man3/tomo-Num.sinh.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.sinh 3 2025-04-19T14:30:40.363864 "Tomo man-pages" +.SH NAME +Num.sinh \- Computes the hyperbolic sine of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.sinh : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the hyperbolic sine of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the hyperbolic sine is to be calculated. - +.TE +.SH RETURN +The hyperbolic sine of `x`. + +.SH EXAMPLES +.EX +>> (0.0).sinh() += 0 +.EE diff --git a/man/man3/tomo-Num.sqrt.3 b/man/man3/tomo-Num.sqrt.3 new file mode 100644 index 00000000..f6feb3b6 --- /dev/null +++ b/man/man3/tomo-Num.sqrt.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.sqrt 3 2025-04-19T14:30:40.363914 "Tomo man-pages" +.SH NAME +Num.sqrt \- Computes the square root of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.sqrt : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the square root of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the square root is to be calculated. - +.TE +.SH RETURN +The square root of `x`. + +.SH EXAMPLES +.EX +>> (16.0).sqrt() += 4 +.EE diff --git a/man/man3/tomo-Num.tan.3 b/man/man3/tomo-Num.tan.3 new file mode 100644 index 00000000..079f6929 --- /dev/null +++ b/man/man3/tomo-Num.tan.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.tan 3 2025-04-19T14:30:40.363954 "Tomo man-pages" +.SH NAME +Num.tan \- Computes the tangent of a number (angle in radians). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.tan : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the tangent of a number (angle in radians). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The angle in radians. - +.TE +.SH RETURN +The tangent of `x`. + +.SH EXAMPLES +.EX +>> (0.0).tan() += 0 +.EE diff --git a/man/man3/tomo-Num.tanh.3 b/man/man3/tomo-Num.tanh.3 new file mode 100644 index 00000000..91c3307a --- /dev/null +++ b/man/man3/tomo-Num.tanh.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.tanh 3 2025-04-19T14:30:40.364021 "Tomo man-pages" +.SH NAME +Num.tanh \- Computes the hyperbolic tangent of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.tanh : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the hyperbolic tangent of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the hyperbolic tangent is to be calculated. - +.TE +.SH RETURN +The hyperbolic tangent of `x`. + +.SH EXAMPLES +.EX +>> (0.0).tanh() += 0 +.EE diff --git a/man/man3/tomo-Num.tgamma.3 b/man/man3/tomo-Num.tgamma.3 new file mode 100644 index 00000000..2ad83495 --- /dev/null +++ b/man/man3/tomo-Num.tgamma.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.tgamma 3 2025-04-19T14:30:40.364064 "Tomo man-pages" +.SH NAME +Num.tgamma \- Computes the gamma function of a number. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.tgamma : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the gamma function of a number. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the gamma function is to be calculated. - +.TE +.SH RETURN +The gamma function of `x`. + +.SH EXAMPLES +.EX +>> (1.0).tgamma() += 1 +.EE diff --git a/man/man3/tomo-Num.trunc.3 b/man/man3/tomo-Num.trunc.3 new file mode 100644 index 00000000..9c72b39c --- /dev/null +++ b/man/man3/tomo-Num.trunc.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.trunc 3 2025-04-19T14:30:40.364102 "Tomo man-pages" +.SH NAME +Num.trunc \- Truncates a number to the nearest integer towards zero. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.trunc : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Truncates a number to the nearest integer towards zero. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number to be truncated. - +.TE +.SH RETURN +The integer part of `x` towards zero. + +.SH EXAMPLES +.EX +>> (3.7).trunc() += 3 +>> (-3.7).trunc() += -3 +.EE diff --git a/man/man3/tomo-Num.y0.3 b/man/man3/tomo-Num.y0.3 new file mode 100644 index 00000000..593924e4 --- /dev/null +++ b/man/man3/tomo-Num.y0.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.y0 3 2025-04-19T14:30:40.364161 "Tomo man-pages" +.SH NAME +Num.y0 \- Computes the Bessel function of the second kind of order 0. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.y0 : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the Bessel function of the second kind of order 0. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the Bessel function is to be calculated. - +.TE +.SH RETURN +The Bessel function of the second kind of order 0 of `x`. + +.SH EXAMPLES +.EX +>> (1.0).y0() += -0.7652 +.EE diff --git a/man/man3/tomo-Num.y1.3 b/man/man3/tomo-Num.y1.3 new file mode 100644 index 00000000..eadb9dc9 --- /dev/null +++ b/man/man3/tomo-Num.y1.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Num.y1 3 2025-04-19T14:30:40.364215 "Tomo man-pages" +.SH NAME +Num.y1 \- Computes the Bessel function of the second kind of order 1. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Num.y1 : func(x: Num -> Num)" +.fi + +.SH DESCRIPTION +Computes the Bessel function of the second kind of order 1. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +x Num The number for which the Bessel function is to be calculated. - +.TE +.SH RETURN +The Bessel function of the second kind of order 1 of `x`. + +.SH EXAMPLES +.EX +>> (1.0).y1() += 0.4401 +.EE diff --git a/man/man3/tomo-Path.accessed.3 b/man/man3/tomo-Path.accessed.3 new file mode 100644 index 00000000..eba79006 --- /dev/null +++ b/man/man3/tomo-Path.accessed.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.accessed 3 2025-04-19T14:30:40.364725 "Tomo man-pages" +.SH NAME +Path.accessed \- Gets the file access time of a file. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.accessed : func(path: Path, follow_symlinks: Bool = yes -> Int64?)" +.fi + +.SH DESCRIPTION +Gets the file access time of a file. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file whose access time you want. - +follow_symlinks Bool Whether to follow symbolic links. yes +.TE +.SH RETURN +A 64-bit unix epoch timestamp representing when the file or directory was last accessed, or `none` if no such file or directory exists. + +.SH EXAMPLES +.EX +>> (./file.txt).accessed() += 1704221100? +>> (./not-a-file).accessed() += none +.EE diff --git a/man/man3/tomo-Path.append.3 b/man/man3/tomo-Path.append.3 new file mode 100644 index 00000000..c008cb66 --- /dev/null +++ b/man/man3/tomo-Path.append.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.append 3 2025-04-19T14:30:40.364773 "Tomo man-pages" +.SH NAME +Path.append \- Appends the given text to the file at the specified path, creating the file if it doesn't already exist. Failure to write will result in a runtime error. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.append : func(path: Path, text: Text, permissions: Int32 = Int32(0o644) -> Void)" +.fi + +.SH DESCRIPTION +Appends the given text to the file at the specified path, creating the file if it doesn't already exist. Failure to write will result in a runtime error. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file to append to. - +text Text The text to append to the file. - +permissions Int32 The permissions to set on the file if it is being created. Int32(0o644) +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +(./log.txt).append("extra line$(\\n)") +.EE diff --git a/man/man3/tomo-Path.append_bytes.3 b/man/man3/tomo-Path.append_bytes.3 new file mode 100644 index 00000000..01bda089 --- /dev/null +++ b/man/man3/tomo-Path.append_bytes.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.append_bytes 3 2025-04-19T14:30:40.364816 "Tomo man-pages" +.SH NAME +Path.append_bytes \- Appends the given bytes to the file at the specified path, creating the file if it doesn't already exist. Failure to write will result in a runtime error. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.append_bytes : func(path: Path, bytes: [Byte], permissions: Int32 = Int32(0o644) -> Void)" +.fi + +.SH DESCRIPTION +Appends the given bytes to the file at the specified path, creating the file if it doesn't already exist. Failure to write will result in a runtime error. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file to append to. - +bytes [Byte] The bytes to append to the file. - +permissions Int32 The permissions to set on the file if it is being created. Int32(0o644) +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +(./log.txt).append_bytes([104, 105]) +.EE diff --git a/man/man3/tomo-Path.base_name.3 b/man/man3/tomo-Path.base_name.3 new file mode 100644 index 00000000..3838ead2 --- /dev/null +++ b/man/man3/tomo-Path.base_name.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.base_name 3 2025-04-19T14:30:40.364857 "Tomo man-pages" +.SH NAME +Path.base_name \- Returns the base name of the file or directory at the specified path. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.base_name : func(path: Path -> Text)" +.fi + +.SH DESCRIPTION +Returns the base name of the file or directory at the specified path. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file or directory. - +.TE +.SH RETURN +The base name of the file or directory. + +.SH EXAMPLES +.EX +>> (./path/to/file.txt).base_name() += "file.txt" +.EE diff --git a/man/man3/tomo-Path.by_line.3 b/man/man3/tomo-Path.by_line.3 new file mode 100644 index 00000000..2770833c --- /dev/null +++ b/man/man3/tomo-Path.by_line.3 @@ -0,0 +1,42 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.by_line 3 2025-04-19T14:30:40.364894 "Tomo man-pages" +.SH NAME +Path.by_line \- Returns an iterator that can be used to iterate over a file one line at a time, or returns a null value if the file could not be opened. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.by_line : func(path: Path -> func(->Text?)?)" +.fi + +.SH DESCRIPTION +Returns an iterator that can be used to iterate over a file one line at a time, or returns a null value if the file could not be opened. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file. - +.TE +.SH RETURN +An iterator that can be used to get lines from a file one at a time or a null value if the file couldn't be read. + +.SH EXAMPLES +.EX +# Safely handle file not being readable: +if lines := (./file.txt).by_line() +for line in lines +say(line.upper()) +else +say("Couldn't read file!") + +# Assume the file is readable and error if that's not the case: +for line in (/dev/stdin).by_line()! +say(line.upper()) +.EE diff --git a/man/man3/tomo-Path.can_execute.3 b/man/man3/tomo-Path.can_execute.3 new file mode 100644 index 00000000..eb0a0cb6 --- /dev/null +++ b/man/man3/tomo-Path.can_execute.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.can_execute 3 2025-04-19T14:30:40.364935 "Tomo man-pages" +.SH NAME +Path.can_execute \- Returns whether or not a file can be executed by the current user/group. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.can_execute : func(path: Path -> Bool)" +.fi + +.SH DESCRIPTION +Returns whether or not a file can be executed by the current user/group. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file to check. - +.TE +.SH RETURN +`yes` if the file or directory exists and the current user has execute permissions, otherwise `no`. + +.SH EXAMPLES +.EX +>> (/bin/sh).can_execute() += yes +>> (/usr/include/stdlib.h).can_execute() += no +>> (/non/existant/file).can_execute() += no +.EE diff --git a/man/man3/tomo-Path.can_read.3 b/man/man3/tomo-Path.can_read.3 new file mode 100644 index 00000000..f54f9362 --- /dev/null +++ b/man/man3/tomo-Path.can_read.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.can_read 3 2025-04-19T14:30:40.364972 "Tomo man-pages" +.SH NAME +Path.can_read \- Returns whether or not a file can be read by the current user/group. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.can_read : func(path: Path -> Bool)" +.fi + +.SH DESCRIPTION +Returns whether or not a file can be read by the current user/group. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file to check. - +.TE +.SH RETURN +`yes` if the file or directory exists and the current user has read permissions, otherwise `no`. + +.SH EXAMPLES +.EX +>> (/usr/include/stdlib.h).can_read() += yes +>> (/etc/shadow).can_read() += no +>> (/non/existant/file).can_read() += no +.EE diff --git a/man/man3/tomo-Path.can_write.3 b/man/man3/tomo-Path.can_write.3 new file mode 100644 index 00000000..af27a504 --- /dev/null +++ b/man/man3/tomo-Path.can_write.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.can_write 3 2025-04-19T14:30:40.365009 "Tomo man-pages" +.SH NAME +Path.can_write \- Returns whether or not a file can be written by the current user/group. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.can_write : func(path: Path -> Bool)" +.fi + +.SH DESCRIPTION +Returns whether or not a file can be written by the current user/group. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file to check. - +.TE +.SH RETURN +`yes` if the file or directory exists and the current user has write permissions, otherwise `no`. + +.SH EXAMPLES +.EX +>> (/tmp).can_write() += yes +>> (/etc/passwd).can_write() += no +>> (/non/existant/file).can_write() += no +.EE diff --git a/man/man3/tomo-Path.changed.3 b/man/man3/tomo-Path.changed.3 new file mode 100644 index 00000000..56d8fd97 --- /dev/null +++ b/man/man3/tomo-Path.changed.3 @@ -0,0 +1,40 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.changed 3 2025-04-19T14:30:40.365046 "Tomo man-pages" +.SH NAME +Path.changed \- Gets the file change time of a file. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.changed : func(path: Path, follow_symlinks: Bool = yes -> Int64?)" +.fi + +.SH DESCRIPTION +Gets the file change time of a file. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file whose change time you want. - +follow_symlinks Bool Whether to follow symbolic links. yes +.TE +.SH RETURN +A 64-bit unix epoch timestamp representing when the file or directory was last changed, or `none` if no such file or directory exists. + +.SH NOTES +This is the ["ctime"](https://en.wikipedia.org/wiki/Stat_(system_call)#ctime) of a file, which is _not_ the file creation time. + +.SH EXAMPLES +.EX +>> (./file.txt).changed() += 1704221100? +>> (./not-a-file).changed() += none +.EE diff --git a/man/man3/tomo-Path.child.3 b/man/man3/tomo-Path.child.3 new file mode 100644 index 00000000..7ae2799a --- /dev/null +++ b/man/man3/tomo-Path.child.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.child 3 2025-04-19T14:30:40.365083 "Tomo man-pages" +.SH NAME +Path.child \- Return a path that is a child of another path. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.child : func(path: Path, child: Text -> [Path])" +.fi + +.SH DESCRIPTION +Return a path that is a child of another path. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of a directory. - +child Text The name of a child file or directory. - +.TE +.SH RETURN +A new path representing the child. + +.SH EXAMPLES +.EX +>> (./directory).child("file.txt") += (./directory/file.txt) +.EE diff --git a/man/man3/tomo-Path.children.3 b/man/man3/tomo-Path.children.3 new file mode 100644 index 00000000..acbc92ff --- /dev/null +++ b/man/man3/tomo-Path.children.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.children 3 2025-04-19T14:30:40.365120 "Tomo man-pages" +.SH NAME +Path.children \- Returns a list of children (files and directories) within the directory at the specified path. Optionally includes hidden files. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.children : func(path: Path, include_hidden = no -> [Path])" +.fi + +.SH DESCRIPTION +Returns a list of children (files and directories) within the directory at the specified path. Optionally includes hidden files. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the directory. - +include_hidden Whether to include hidden files, which start with a `.`. no +.TE +.SH RETURN +A list of paths for the children. + +.SH EXAMPLES +.EX +>> (./directory).children(include_hidden=yes) += [".git", "foo.txt"] +.EE diff --git a/man/man3/tomo-Path.create_directory.3 b/man/man3/tomo-Path.create_directory.3 new file mode 100644 index 00000000..ef498a1a --- /dev/null +++ b/man/man3/tomo-Path.create_directory.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.create_directory 3 2025-04-19T14:30:40.365156 "Tomo man-pages" +.SH NAME +Path.create_directory \- Creates a new directory at the specified path with the given permissions. If any of the parent directories do not exist, they will be created as needed. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.create_directory : func(path: Path, permissions = Int32(0o755) -> Void)" +.fi + +.SH DESCRIPTION +Creates a new directory at the specified path with the given permissions. If any of the parent directories do not exist, they will be created as needed. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the directory to create. - +permissions The permissions to set on the new directory. Int32(0o755) +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +(./new_directory).create_directory() +.EE diff --git a/man/man3/tomo-Path.current_dir.3 b/man/man3/tomo-Path.current_dir.3 new file mode 100644 index 00000000..5838aa64 --- /dev/null +++ b/man/man3/tomo-Path.current_dir.3 @@ -0,0 +1,26 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.current_dir 3 2025-04-19T14:30:40.365191 "Tomo man-pages" +.SH NAME +Path.current_dir \- Creates a new directory at the specified path with the given permissions. If any of the parent directories do not exist, they will be created as needed. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.current_dir : func(-> Path)" +.fi + +.SH DESCRIPTION +Creates a new directory at the specified path with the given permissions. If any of the parent directories do not exist, they will be created as needed. + +.SH RETURN +The absolute path of the current directory. + +.SH EXAMPLES +.EX +>> Path.current_dir() += (/home/user/tomo) +.EE diff --git a/man/man3/tomo-Path.exists.3 b/man/man3/tomo-Path.exists.3 new file mode 100644 index 00000000..ea01f95b --- /dev/null +++ b/man/man3/tomo-Path.exists.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.exists 3 2025-04-19T14:30:40.365224 "Tomo man-pages" +.SH NAME +Path.exists \- Checks if a file or directory exists at the specified path. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.exists : func(path: Path -> Bool)" +.fi + +.SH DESCRIPTION +Checks if a file or directory exists at the specified path. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path to check. - +.TE +.SH RETURN +`True` if the file or directory exists, `False` otherwise. + +.SH EXAMPLES +.EX +>> (/).exists() += yes +.EE diff --git a/man/man3/tomo-Path.expand_home.3 b/man/man3/tomo-Path.expand_home.3 new file mode 100644 index 00000000..389bee30 --- /dev/null +++ b/man/man3/tomo-Path.expand_home.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.expand_home 3 2025-04-19T14:30:40.365279 "Tomo man-pages" +.SH NAME +Path.expand_home \- For home-based paths (those starting with `~`), expand the path to replace the tilde with and absolute path to the user's `$HOME` directory. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.expand_home : func(path: Path -> Path)" +.fi + +.SH DESCRIPTION +For home-based paths (those starting with `~`), expand the path to replace the tilde with and absolute path to the user's `$HOME` directory. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path to expand. - +.TE +.SH RETURN +If the path does not start with a `~`, then return it unmodified. Otherwise, replace the `~` with an absolute path to the user's home directory. + +.SH EXAMPLES +.EX +>> (~/foo).expand_home() # Assume current user is 'user' += /home/user/foo +>> (/foo).expand_home() # No change += /foo +.EE diff --git a/man/man3/tomo-Path.extension.3 b/man/man3/tomo-Path.extension.3 new file mode 100644 index 00000000..3fb13fc7 --- /dev/null +++ b/man/man3/tomo-Path.extension.3 @@ -0,0 +1,41 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.extension 3 2025-04-19T14:30:40.365321 "Tomo man-pages" +.SH NAME +Path.extension \- Returns the file extension of the file at the specified path. Optionally returns the full extension. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.extension : func(path: Path, full: Bool = yes -> Text)" +.fi + +.SH DESCRIPTION +Returns the file extension of the file at the specified path. Optionally returns the full extension. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file. - +full Bool Whether to return everything after the first `.` in the base name, or only the last part of the extension. yes +.TE +.SH RETURN +The file extension (not including the leading `.`) or an empty text if there is no file extension. + +.SH EXAMPLES +.EX +>> (./file.tar.gz).extension() += "tar.gz" +>> (./file.tar.gz).extension(full=no) += "gz" +>> (/foo).extension() += "" +>> (./.git).extension() += "" +.EE diff --git a/man/man3/tomo-Path.files.3 b/man/man3/tomo-Path.files.3 new file mode 100644 index 00000000..e1df767b --- /dev/null +++ b/man/man3/tomo-Path.files.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.files 3 2025-04-19T14:30:40.365361 "Tomo man-pages" +.SH NAME +Path.files \- Returns a list of files within the directory at the specified path. Optionally includes hidden files. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.files : func(path: Path, include_hidden: Bool = no -> [Path])" +.fi + +.SH DESCRIPTION +Returns a list of files within the directory at the specified path. Optionally includes hidden files. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the directory. - +include_hidden Bool Whether to include hidden files. no +.TE +.SH RETURN +A list of file paths. + +.SH EXAMPLES +.EX +>> (./directory).files(include_hidden=yes) += [(./directory/file1.txt), (./directory/file2.txt)] +.EE diff --git a/man/man3/tomo-Path.from_components.3 b/man/man3/tomo-Path.from_components.3 new file mode 100644 index 00000000..cb5879c1 --- /dev/null +++ b/man/man3/tomo-Path.from_components.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.from_components 3 2025-04-19T14:30:40.365399 "Tomo man-pages" +.SH NAME +Path.from_components \- Returns a path built from a list of path components. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.from_components : func(components: [Text] -> Path)" +.fi + +.SH DESCRIPTION +Returns a path built from a list of path components. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +components [Text] A list of path components. - +.TE +.SH RETURN +A path representing the given components. + +.SH EXAMPLES +.EX +>> Path.from_components(["/", "usr", "include"]) += /usr/include +>> Path.from_components(["foo.txt"]) += ./foo.txt +>> Path.from_components(["~", ".local"]) += ~/.local +.EE diff --git a/man/man3/tomo-Path.glob.3 b/man/man3/tomo-Path.glob.3 new file mode 100644 index 00000000..8d48171e --- /dev/null +++ b/man/man3/tomo-Path.glob.3 @@ -0,0 +1,60 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.glob 3 2025-04-19T14:30:40.365437 "Tomo man-pages" +.SH NAME +Path.glob \- Perform a globbing operation and return a list of matching paths. Some glob specific details: +- The paths "." and ".." are *not* included in any globbing results. +- Files or directories that begin with "." will not match `*`, but will match `.*`. +- Globs do support `{a,b}` syntax for matching files that match any of several + choices of patterns. + +- The shell-style syntax `**` for matching subdirectories is not supported. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.glob : func(path: Path -> [Path])" +.fi + +.SH DESCRIPTION +Perform a globbing operation and return a list of matching paths. Some glob specific details: +- The paths "." and ".." are *not* included in any globbing results. +- Files or directories that begin with "." will not match `*`, but will match `.*`. +- Globs do support `{a,b}` syntax for matching files that match any of several + choices of patterns. + +- The shell-style syntax `**` for matching subdirectories is not supported. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the directory which may contain special globbing characters like `*`, `?`, or `{...}` - +.TE +.SH RETURN +A list of file paths that match the glob. + +.SH EXAMPLES +.EX +# Current directory includes: foo.txt, baz.txt, qux.jpg, .hidden +>> (./*).glob() += [(./foo.txt), (./baz.txt), (./qux.jpg)] + +>> (./*.txt).glob() += [(./foo.txt), (./baz.txt)] + +>> (./*.{txt,jpg}).glob() += [(./foo.txt), (./baz.txt), (./qux.jpg)] + +>> (./.*).glob() += [(./.hidden)] + +# Globs with no matches return an empty list: +>> (./*.xxx).glob() += [] +.EE diff --git a/man/man3/tomo-Path.group.3 b/man/man3/tomo-Path.group.3 new file mode 100644 index 00000000..615f5777 --- /dev/null +++ b/man/man3/tomo-Path.group.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.group 3 2025-04-19T14:30:40.365486 "Tomo man-pages" +.SH NAME +Path.group \- Get the owning group of a file or directory. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.group : func(path: Path, follow_symlinks: Bool = yes -> Text?)" +.fi + +.SH DESCRIPTION +Get the owning group of a file or directory. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path whose owning group to get. - +follow_symlinks Bool Whether to follow symbolic links. yes +.TE +.SH RETURN +The name of the group which owns the file or directory, or `none` if the path does not exist. + +.SH EXAMPLES +.EX +>> (/bin).group() += "root" +>> (/non/existent/file).group() += none +.EE diff --git a/man/man3/tomo-Path.is_directory.3 b/man/man3/tomo-Path.is_directory.3 new file mode 100644 index 00000000..89953dcc --- /dev/null +++ b/man/man3/tomo-Path.is_directory.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.is_directory 3 2025-04-19T14:30:40.365526 "Tomo man-pages" +.SH NAME +Path.is_directory \- Checks if the path represents a directory. Optionally follows symbolic links. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.is_directory : func(path: Path, follow_symlinks = yes -> Bool)" +.fi + +.SH DESCRIPTION +Checks if the path represents a directory. Optionally follows symbolic links. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path to check. - +follow_symlinks Whether to follow symbolic links. yes +.TE +.SH RETURN +`True` if the path is a directory, `False` otherwise. + +.SH EXAMPLES +.EX +>> (./directory/).is_directory() += yes + +>> (./file.txt).is_directory() += no +.EE diff --git a/man/man3/tomo-Path.is_file.3 b/man/man3/tomo-Path.is_file.3 new file mode 100644 index 00000000..9bb6fb56 --- /dev/null +++ b/man/man3/tomo-Path.is_file.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.is_file 3 2025-04-19T14:30:40.365567 "Tomo man-pages" +.SH NAME +Path.is_file \- Checks if the path represents a file. Optionally follows symbolic links. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.is_file : func(path: Path, follow_symlinks = yes -> Bool)" +.fi + +.SH DESCRIPTION +Checks if the path represents a file. Optionally follows symbolic links. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path to check. - +follow_symlinks Whether to follow symbolic links. yes +.TE +.SH RETURN +`True` if the path is a file, `False` otherwise. + +.SH EXAMPLES +.EX +>> (./file.txt).is_file() += yes + +>> (./directory/).is_file() += no +.EE diff --git a/man/man3/tomo-Path.is_socket.3 b/man/man3/tomo-Path.is_socket.3 new file mode 100644 index 00000000..b7465f78 --- /dev/null +++ b/man/man3/tomo-Path.is_socket.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.is_socket 3 2025-04-19T14:30:40.365604 "Tomo man-pages" +.SH NAME +Path.is_socket \- Checks if the path represents a socket. Optionally follows symbolic links. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.is_socket : func(path: Path, follow_symlinks = yes -> Bool)" +.fi + +.SH DESCRIPTION +Checks if the path represents a socket. Optionally follows symbolic links. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path to check. - +follow_symlinks Whether to follow symbolic links. yes +.TE +.SH RETURN +`True` if the path is a socket, `False` otherwise. + +.SH EXAMPLES +.EX +>> (./socket).is_socket() += yes +.EE diff --git a/man/man3/tomo-Path.is_symlink.3 b/man/man3/tomo-Path.is_symlink.3 new file mode 100644 index 00000000..d1a743bb --- /dev/null +++ b/man/man3/tomo-Path.is_symlink.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.is_symlink 3 2025-04-19T14:30:40.365640 "Tomo man-pages" +.SH NAME +Path.is_symlink \- Checks if the path represents a symbolic link. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.is_symlink : func(path: Path -> Bool)" +.fi + +.SH DESCRIPTION +Checks if the path represents a symbolic link. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path to check. - +.TE +.SH RETURN +`True` if the path is a symbolic link, `False` otherwise. + +.SH EXAMPLES +.EX +>> (./link).is_symlink() += yes +.EE diff --git a/man/man3/tomo-Path.modified.3 b/man/man3/tomo-Path.modified.3 new file mode 100644 index 00000000..f7c5f48d --- /dev/null +++ b/man/man3/tomo-Path.modified.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.modified 3 2025-04-19T14:30:40.365676 "Tomo man-pages" +.SH NAME +Path.modified \- Gets the file modification time of a file. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.modified : func(path: Path, follow_symlinks: Bool = yes -> Int64?)" +.fi + +.SH DESCRIPTION +Gets the file modification time of a file. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file whose modification time you want. - +follow_symlinks Bool Whether to follow symbolic links. yes +.TE +.SH RETURN +A 64-bit unix epoch timestamp representing when the file or directory was last modified, or `none` if no such file or directory exists. + +.SH EXAMPLES +.EX +>> (./file.txt).modified() += 1704221100? +>> (./not-a-file).modified() += none +.EE diff --git a/man/man3/tomo-Path.owner.3 b/man/man3/tomo-Path.owner.3 new file mode 100644 index 00000000..65d66404 --- /dev/null +++ b/man/man3/tomo-Path.owner.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.owner 3 2025-04-19T14:30:40.365713 "Tomo man-pages" +.SH NAME +Path.owner \- Get the owning user of a file or directory. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.owner : func(path: Path, follow_symlinks: Bool = yes -> Text?)" +.fi + +.SH DESCRIPTION +Get the owning user of a file or directory. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path whose owner to get. - +follow_symlinks Bool Whether to follow symbolic links. yes +.TE +.SH RETURN +The name of the user who owns the file or directory, or `none` if the path does not exist. + +.SH EXAMPLES +.EX +>> (/bin).owner() += "root" +>> (/non/existent/file).owner() += none +.EE diff --git a/man/man3/tomo-Path.parent.3 b/man/man3/tomo-Path.parent.3 new file mode 100644 index 00000000..36d33058 --- /dev/null +++ b/man/man3/tomo-Path.parent.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.parent 3 2025-04-19T14:30:40.365748 "Tomo man-pages" +.SH NAME +Path.parent \- Returns the parent directory of the file or directory at the specified path. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.parent : func(path: Path -> Path)" +.fi + +.SH DESCRIPTION +Returns the parent directory of the file or directory at the specified path. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file or directory. - +.TE +.SH RETURN +The path of the parent directory. + +.SH EXAMPLES +.EX +>> (./path/to/file.txt).parent() += (./path/to/) +.EE diff --git a/man/man3/tomo-Path.read.3 b/man/man3/tomo-Path.read.3 new file mode 100644 index 00000000..13630d96 --- /dev/null +++ b/man/man3/tomo-Path.read.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.read 3 2025-04-19T14:30:40.365795 "Tomo man-pages" +.SH NAME +Path.read \- Reads the contents of the file at the specified path or a null value if the file could not be read. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.read : func(path: Path -> Text?)" +.fi + +.SH DESCRIPTION +Reads the contents of the file at the specified path or a null value if the file could not be read. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file to read. - +.TE +.SH RETURN +The contents of the file. If the file could not be read, a null value will be returned. If the file can be read, but is not valid UTF8 data, an error will be raised. + +.SH EXAMPLES +.EX +>> (./hello.txt).read() += "Hello"? + +>> (./nosuchfile.xxx).read() += none +.EE diff --git a/man/man3/tomo-Path.read_bytes.3 b/man/man3/tomo-Path.read_bytes.3 new file mode 100644 index 00000000..b1be93e9 --- /dev/null +++ b/man/man3/tomo-Path.read_bytes.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.read_bytes 3 2025-04-19T14:30:40.365850 "Tomo man-pages" +.SH NAME +Path.read_bytes \- Reads the contents of the file at the specified path or a null value if the file could not be read. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.read_bytes : func(path: Path, limit: Int? = none -> [Byte]?)" +.fi + +.SH DESCRIPTION +Reads the contents of the file at the specified path or a null value if the file could not be read. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file to read. - +limit Int? A limit to how many bytes should be read. none +.TE +.SH RETURN +The byte contents of the file. If the file cannot be read, a null value will be returned. + +.SH EXAMPLES +.EX +>> (./hello.txt).read() += [72, 101, 108, 108, 111]? + +>> (./nosuchfile.xxx).read() += none +.EE diff --git a/man/man3/tomo-Path.relative_to.3 b/man/man3/tomo-Path.relative_to.3 new file mode 100644 index 00000000..b2ee1ce3 --- /dev/null +++ b/man/man3/tomo-Path.relative_to.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.relative_to 3 2025-04-19T14:30:40.365893 "Tomo man-pages" +.SH NAME +Path.relative_to \- Returns the path relative to a given base path. By default, the base path is the current directory. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.relative_to : func(path: Path, relative_to = (./) -> Path)" +.fi + +.SH DESCRIPTION +Returns the path relative to a given base path. By default, the base path is the current directory. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path to convert. - +relative_to The base path for the relative path. (./) +.TE +.SH RETURN +The relative path. + +.SH EXAMPLES +.EX +>> (./path/to/file.txt).relative(relative_to=(./path)) += (./to/file.txt) +.EE diff --git a/man/man3/tomo-Path.remove.3 b/man/man3/tomo-Path.remove.3 new file mode 100644 index 00000000..252e9665 --- /dev/null +++ b/man/man3/tomo-Path.remove.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.remove 3 2025-04-19T14:30:40.365933 "Tomo man-pages" +.SH NAME +Path.remove \- Removes the file or directory at the specified path. A runtime error is raised if something goes wrong. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.remove : func(path: Path, ignore_missing = no -> Void)" +.fi + +.SH DESCRIPTION +Removes the file or directory at the specified path. A runtime error is raised if something goes wrong. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path to remove. - +ignore_missing Whether to ignore errors if the file or directory does not exist. no +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +(./file.txt).remove() +.EE diff --git a/man/man3/tomo-Path.resolved.3 b/man/man3/tomo-Path.resolved.3 new file mode 100644 index 00000000..afc67b8a --- /dev/null +++ b/man/man3/tomo-Path.resolved.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.resolved 3 2025-04-19T14:30:40.365971 "Tomo man-pages" +.SH NAME +Path.resolved \- Resolves the absolute path of the given path relative to a base path. By default, the base path is the current directory. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.resolved : func(path: Path, relative_to = (./) -> Path)" +.fi + +.SH DESCRIPTION +Resolves the absolute path of the given path relative to a base path. By default, the base path is the current directory. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path to resolve. - +relative_to The base path for resolution. (./) +.TE +.SH RETURN +The resolved absolute path. + +.SH EXAMPLES +.EX +>> (~/foo).resolved() += (/home/user/foo) + +>> (./path/to/file.txt).resolved(relative_to=(/foo)) += (/foo/path/to/file.txt) +.EE diff --git a/man/man3/tomo-Path.set_owner.3 b/man/man3/tomo-Path.set_owner.3 new file mode 100644 index 00000000..24e8f697 --- /dev/null +++ b/man/man3/tomo-Path.set_owner.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.set_owner 3 2025-04-19T14:30:40.366011 "Tomo man-pages" +.SH NAME +Path.set_owner \- Set the owning user and/or group for a path. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.set_owner : func(path: Path, owner: Text? = none, group: Text? = none, follow_symlinks: Bool = yes -> Void)" +.fi + +.SH DESCRIPTION +Set the owning user and/or group for a path. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path to change the permissions for. - +owner Text? If non-none, the new user to assign to be the owner of the file. none +group Text? If non-none, the new group to assign to be the owner of the file. none +follow_symlinks Bool Whether to follow symbolic links. yes +.TE +.SH RETURN +Nothing. If a path does not exist, a failure will be raised. + +.SH EXAMPLES +.EX +(./file.txt).set_owner(owner="root", group="wheel") +.EE diff --git a/man/man3/tomo-Path.subdirectories.3 b/man/man3/tomo-Path.subdirectories.3 new file mode 100644 index 00000000..16c68be4 --- /dev/null +++ b/man/man3/tomo-Path.subdirectories.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.subdirectories 3 2025-04-19T14:30:40.366051 "Tomo man-pages" +.SH NAME +Path.subdirectories \- Returns a list of subdirectories within the directory at the specified path. Optionally includes hidden subdirectories. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.subdirectories : func(path: Path, include_hidden = no -> [Path])" +.fi + +.SH DESCRIPTION +Returns a list of subdirectories within the directory at the specified path. Optionally includes hidden subdirectories. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the directory. - +include_hidden Whether to include hidden subdirectories. no +.TE +.SH RETURN +A list of subdirectory paths. + +.SH EXAMPLES +.EX +>> (./directory).subdirectories() += [(./directory/subdir1), (./directory/subdir2)] + +>> (./directory).subdirectories(include_hidden=yes) += [(./directory/.git), (./directory/subdir1), (./directory/subdir2)] +.EE diff --git a/man/man3/tomo-Path.unique_directory.3 b/man/man3/tomo-Path.unique_directory.3 new file mode 100644 index 00000000..b7e4cfb8 --- /dev/null +++ b/man/man3/tomo-Path.unique_directory.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.unique_directory 3 2025-04-19T14:30:40.366088 "Tomo man-pages" +.SH NAME +Path.unique_directory \- Generates a unique directory path based on the given path. Useful for creating temporary directories. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.unique_directory : func(path: Path -> Path)" +.fi + +.SH DESCRIPTION +Generates a unique directory path based on the given path. Useful for creating temporary directories. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The base path for generating the unique directory. The last six letters of this path must be `XXXXXX`. - +.TE +.SH RETURN +A unique directory path after creating the directory. + +.SH EXAMPLES +.EX +>> created := (/tmp/my-dir.XXXXXX).unique_directory() += (/tmp/my-dir-AwoxbM/) +>> created.is_directory() += yes +created.remove() +.EE diff --git a/man/man3/tomo-Path.write.3 b/man/man3/tomo-Path.write.3 new file mode 100644 index 00000000..7dd28ab0 --- /dev/null +++ b/man/man3/tomo-Path.write.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.write 3 2025-04-19T14:30:40.366125 "Tomo man-pages" +.SH NAME +Path.write \- Writes the given text to the file at the specified path, creating the file if it doesn't already exist. Sets the file permissions as specified. If the file writing cannot be successfully completed, a runtime error is raised. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.write : func(path: Path, text: Text, permissions = Int32(0o644) -> Void)" +.fi + +.SH DESCRIPTION +Writes the given text to the file at the specified path, creating the file if it doesn't already exist. Sets the file permissions as specified. If the file writing cannot be successfully completed, a runtime error is raised. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file to write to. - +text Text The text to write to the file. - +permissions The permissions to set on the file if it is created. Int32(0o644) +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +(./file.txt).write("Hello, world!") +.EE diff --git a/man/man3/tomo-Path.write_bytes.3 b/man/man3/tomo-Path.write_bytes.3 new file mode 100644 index 00000000..6cf31725 --- /dev/null +++ b/man/man3/tomo-Path.write_bytes.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.write_bytes 3 2025-04-19T14:30:40.366166 "Tomo man-pages" +.SH NAME +Path.write_bytes \- Writes the given bytes to the file at the specified path, creating the file if it doesn't already exist. Sets the file permissions as specified. If the file writing cannot be successfully completed, a runtime error is raised. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.write_bytes : func(path: Path, bytes: [Byte], permissions = Int32(0o644) -> Void)" +.fi + +.SH DESCRIPTION +Writes the given bytes to the file at the specified path, creating the file if it doesn't already exist. Sets the file permissions as specified. If the file writing cannot be successfully completed, a runtime error is raised. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The path of the file to write to. - +bytes [Byte] A list of bytes to write to the file. - +permissions The permissions to set on the file if it is created. Int32(0o644) +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +(./file.txt).write_bytes([104, 105]) +.EE diff --git a/man/man3/tomo-Path.write_unique.3 b/man/man3/tomo-Path.write_unique.3 new file mode 100644 index 00000000..cb93793b --- /dev/null +++ b/man/man3/tomo-Path.write_unique.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.write_unique 3 2025-04-19T14:30:40.366203 "Tomo man-pages" +.SH NAME +Path.write_unique \- Writes the given text to a unique file path based on the specified path. The file is created if it doesn't exist. This is useful for creating temporary files. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.write_unique : func(path: Path, text: Text -> Path)" +.fi + +.SH DESCRIPTION +Writes the given text to a unique file path based on the specified path. The file is created if it doesn't exist. This is useful for creating temporary files. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The base path for generating the unique file. This path must include the string `XXXXXX` in the file base name. - +text Text The text to write to the file. - +.TE +.SH RETURN +The path of the newly created unique file. + +.SH EXAMPLES +.EX +>> created := (./file-XXXXXX.txt).write_unique("Hello, world!") += (./file-27QHtq.txt) +>> created.read() += "Hello, world!" +created.remove() +.EE diff --git a/man/man3/tomo-Path.write_unique_bytes.3 b/man/man3/tomo-Path.write_unique_bytes.3 new file mode 100644 index 00000000..0aae419f --- /dev/null +++ b/man/man3/tomo-Path.write_unique_bytes.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Path.write_unique_bytes 3 2025-04-19T14:30:40.366241 "Tomo man-pages" +.SH NAME +Path.write_unique_bytes \- Writes the given bytes to a unique file path based on the specified path. The file is created if it doesn't exist. This is useful for creating temporary files. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Path.write_unique_bytes : func(path: Path, bytes: [Byte] -> Path)" +.fi + +.SH DESCRIPTION +Writes the given bytes to a unique file path based on the specified path. The file is created if it doesn't exist. This is useful for creating temporary files. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +path Path The base path for generating the unique file. This path must include the string `XXXXXX` in the file base name. - +bytes [Byte] The bytes to write to the file. - +.TE +.SH RETURN +The path of the newly created unique file. + +.SH EXAMPLES +.EX +>> created := (./file-XXXXXX.txt).write_unique_bytes([1, 2, 3]) += (./file-27QHtq.txt) +>> created.read() += [1, 2, 3] +created.remove() +.EE diff --git a/man/man3/tomo-Set.add.3 b/man/man3/tomo-Set.add.3 new file mode 100644 index 00000000..6ebfb5a4 --- /dev/null +++ b/man/man3/tomo-Set.add.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Set.add 3 2025-04-19T14:30:40.366278 "Tomo man-pages" +.SH NAME +Set.add \- Adds an item to the set. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Set.add : func(set: |T|, item: T -> Void)" +.fi + +.SH DESCRIPTION +Adds an item to the set. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +set |T| The mutable reference to the set. - +item T The item to add to the set. - +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +>> nums.add(42) +.EE diff --git a/man/man3/tomo-Set.add_all.3 b/man/man3/tomo-Set.add_all.3 new file mode 100644 index 00000000..97ccb88a --- /dev/null +++ b/man/man3/tomo-Set.add_all.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Set.add_all 3 2025-04-19T14:30:40.366315 "Tomo man-pages" +.SH NAME +Set.add_all \- Adds multiple items to the set. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Set.add_all : func(set: @|T|, items: [T] -> Void)" +.fi + +.SH DESCRIPTION +Adds multiple items to the set. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +set @|T| The mutable reference to the set. - +items [T] The list of items to add to the set. - +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +>> nums.add_all([1, 2, 3]) +.EE diff --git a/man/man3/tomo-Set.clear.3 b/man/man3/tomo-Set.clear.3 new file mode 100644 index 00000000..0d042f1d --- /dev/null +++ b/man/man3/tomo-Set.clear.3 @@ -0,0 +1,33 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Set.clear 3 2025-04-19T14:30:40.366350 "Tomo man-pages" +.SH NAME +Set.clear \- Removes all items from the set. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Set.clear : func(set: @|T| -> Void)" +.fi + +.SH DESCRIPTION +Removes all items from the set. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +set @|T| The mutable reference to the set. - +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +>> nums.clear() +.EE diff --git a/man/man3/tomo-Set.has.3 b/man/man3/tomo-Set.has.3 new file mode 100644 index 00000000..930658e5 --- /dev/null +++ b/man/man3/tomo-Set.has.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Set.has 3 2025-04-19T14:30:40.366403 "Tomo man-pages" +.SH NAME +Set.has \- Checks if the set contains a specified item. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Set.has : func(set: |T|, item: T -> Bool)" +.fi + +.SH DESCRIPTION +Checks if the set contains a specified item. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +set |T| The set to check. - +item T The item to check for presence. - +.TE +.SH RETURN +`yes` if the item is present, `no` otherwise. + +.SH EXAMPLES +.EX +>> |10, 20|.has(20) += yes +.EE diff --git a/man/man3/tomo-Set.is_subset_of.3 b/man/man3/tomo-Set.is_subset_of.3 new file mode 100644 index 00000000..0d52cffa --- /dev/null +++ b/man/man3/tomo-Set.is_subset_of.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Set.is_subset_of 3 2025-04-19T14:30:40.366444 "Tomo man-pages" +.SH NAME +Set.is_subset_of \- Checks if the set is a subset of another set. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Set.is_subset_of : func(set: |T|, other: |T|, strict: Bool = no -> Bool)" +.fi + +.SH DESCRIPTION +Checks if the set is a subset of another set. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +set |T| The set to check. - +other |T| The set to compare against. - +strict Bool If `yes`, checks if the set is a strict subset (does not equal the other set). no +.TE +.SH RETURN +`yes` if the set is a subset of the other set (strictly or not), `no` otherwise. + +.SH EXAMPLES +.EX +>> |1, 2|.is_subset_of(|1, 2, 3|) += yes +.EE diff --git a/man/man3/tomo-Set.is_superset_of.3 b/man/man3/tomo-Set.is_superset_of.3 new file mode 100644 index 00000000..b3a81756 --- /dev/null +++ b/man/man3/tomo-Set.is_superset_of.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Set.is_superset_of 3 2025-04-19T14:30:40.366494 "Tomo man-pages" +.SH NAME +Set.is_superset_of \- Checks if the set is a superset of another set. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Set.is_superset_of : func(set: |T|, other: |T|, strict: Bool = no -> Bool)" +.fi + +.SH DESCRIPTION +Checks if the set is a superset of another set. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +set |T| The set to check. - +other |T| The set to compare against. - +strict Bool If `yes`, checks if the set is a strict superset (does not equal the other set). no +.TE +.SH RETURN +`yes` if the set is a superset of the other set (strictly or not), `no` otherwise. + +.SH EXAMPLES +.EX +>> |1, 2, 3|.is_superset_of(|1, 2|) += yes +.EE diff --git a/man/man3/tomo-Set.overlap.3 b/man/man3/tomo-Set.overlap.3 new file mode 100644 index 00000000..9dccfa9b --- /dev/null +++ b/man/man3/tomo-Set.overlap.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Set.overlap 3 2025-04-19T14:30:40.366564 "Tomo man-pages" +.SH NAME +Set.overlap \- Creates a new set with items that are in both the original set and another set. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Set.overlap : func(set: |T|, other: |T| -> |T|)" +.fi + +.SH DESCRIPTION +Creates a new set with items that are in both the original set and another set. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +set |T| The original set. - +other |T| The set to intersect with. - +.TE +.SH RETURN +A new set containing only items present in both sets. + +.SH EXAMPLES +.EX +>> |1, 2|.overlap(|2, 3|) += |2| +.EE diff --git a/man/man3/tomo-Set.remove.3 b/man/man3/tomo-Set.remove.3 new file mode 100644 index 00000000..bc9c3291 --- /dev/null +++ b/man/man3/tomo-Set.remove.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Set.remove 3 2025-04-19T14:30:40.366605 "Tomo man-pages" +.SH NAME +Set.remove \- Removes an item from the set. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Set.remove : func(set: @|T|, item: T -> Void)" +.fi + +.SH DESCRIPTION +Removes an item from the set. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +set @|T| The mutable reference to the set. - +item T The item to remove from the set. - +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +>> nums.remove(42) +.EE diff --git a/man/man3/tomo-Set.remove_all.3 b/man/man3/tomo-Set.remove_all.3 new file mode 100644 index 00000000..3eae18d7 --- /dev/null +++ b/man/man3/tomo-Set.remove_all.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Set.remove_all 3 2025-04-19T14:30:40.366645 "Tomo man-pages" +.SH NAME +Set.remove_all \- Removes multiple items from the set. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Set.remove_all : func(set: @|T|, items: [T] -> Void)" +.fi + +.SH DESCRIPTION +Removes multiple items from the set. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +set @|T| The mutable reference to the set. - +items [T] The list of items to remove from the set. - +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +>> nums.remove_all([1, 2, 3]) +.EE diff --git a/man/man3/tomo-Set.with.3 b/man/man3/tomo-Set.with.3 new file mode 100644 index 00000000..54a38871 --- /dev/null +++ b/man/man3/tomo-Set.with.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Set.with 3 2025-04-19T14:30:40.366688 "Tomo man-pages" +.SH NAME +Set.with \- Creates a new set that is the union of the original set and another set. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Set.with : func(set: |T|, other: |T| -> |T|)" +.fi + +.SH DESCRIPTION +Creates a new set that is the union of the original set and another set. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +set |T| The original set. - +other |T| The set to union with. - +.TE +.SH RETURN +A new set containing all items from both sets. + +.SH EXAMPLES +.EX +>> |1, 2|.with(|2, 3|) += |1, 2, 3| +.EE diff --git a/man/man3/tomo-Set.without.3 b/man/man3/tomo-Set.without.3 new file mode 100644 index 00000000..ce0b95e4 --- /dev/null +++ b/man/man3/tomo-Set.without.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Set.without 3 2025-04-19T14:30:40.366726 "Tomo man-pages" +.SH NAME +Set.without \- Creates a new set with items from the original set but without items from another set. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Set.without : func(set: |T|, other: |T| -> |T|)" +.fi + +.SH DESCRIPTION +Creates a new set with items from the original set but without items from another set. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +set |T| The original set. - +other |T| The set of items to remove from the original set. - +.TE +.SH RETURN +A new set containing items from the original set excluding those in the other set. + +.SH EXAMPLES +.EX +>> |1, 2|.without(|2, 3|) += |1| +.EE diff --git a/man/man3/tomo-Table.clear.3 b/man/man3/tomo-Table.clear.3 new file mode 100644 index 00000000..5b61d5e7 --- /dev/null +++ b/man/man3/tomo-Table.clear.3 @@ -0,0 +1,33 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Table.clear 3 2025-04-19T14:30:40.366765 "Tomo man-pages" +.SH NAME +Table.clear \- Removes all key-value pairs from the table. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Table.clear : func(t: &{K=V} -> Void)" +.fi + +.SH DESCRIPTION +Removes all key-value pairs from the table. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +t &{K=V} The reference to the table. - +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +>> t.clear() +.EE diff --git a/man/man3/tomo-Table.get.3 b/man/man3/tomo-Table.get.3 new file mode 100644 index 00000000..8d336835 --- /dev/null +++ b/man/man3/tomo-Table.get.3 @@ -0,0 +1,45 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Table.get 3 2025-04-19T14:30:40.366804 "Tomo man-pages" +.SH NAME +Table.get \- Retrieves the value associated with a key, or returns `none` if the key is not present. **Note:** default values for the table are ignored. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Table.get : func(t: {K=V}, key: K -> V?)" +.fi + +.SH DESCRIPTION +Retrieves the value associated with a key, or returns `none` if the key is not present. **Note:** default values for the table are ignored. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +t {K=V} The table. - +key K The key whose associated value is to be retrieved. - +.TE +.SH RETURN +The value associated with the key or `none` if the key is not found. + +.SH EXAMPLES +.EX +>> t := {"A"=1, "B"=2} +>> t.get("A") += 1? + +>> t.get("????") += none + +>> t.get("A")! += 1 + +>> t.get("????") or 0 += 0 +.EE diff --git a/man/man3/tomo-Table.get_or_set.3 b/man/man3/tomo-Table.get_or_set.3 new file mode 100644 index 00000000..bd39773c --- /dev/null +++ b/man/man3/tomo-Table.get_or_set.3 @@ -0,0 +1,48 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Table.get_or_set 3 2025-04-19T14:30:40.366848 "Tomo man-pages" +.SH NAME +Table.get_or_set \- If the given key is in the table, return the associated value. Otherwise, insert the given default value into the table and return it. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Table.get_or_set : func(t: &{K=V}, key: K, default: V -> V?)" +.fi + +.SH DESCRIPTION +If the given key is in the table, return the associated value. Otherwise, insert the given default value into the table and return it. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +t &{K=V} The table. - +key K The key whose associated value is to be retrieved. - +default V The default value to insert and return if the key is not present in the table. - +.TE +.SH RETURN +Either the value associated with the key (if present) or the default value. The table will be mutated if the key is not already present. + +.SH NOTES +If no default value is provided explicitly, but the table has a default value associated with it, the table's default value will be used. +The default value is only evaluated if the key is missing. + +.SH EXAMPLES +.EX +>> t := &{"A"=@[1, 2, 3]; default=@[]} +>> t.get_or_set("A").insert(4) +>> t.get_or_set("B").insert(99) +>> t += &{"A"=@[1, 2, 3, 4], "B"=@[99]} + +>> t.get_or_set("C", @[0, 0, 0]) += @[0, 0, 0] +>> t += &{"A"=@[1, 2, 3, 4], "B"=@[99], "C"=@[0, 0, 0]} +.EE diff --git a/man/man3/tomo-Table.has.3 b/man/man3/tomo-Table.has.3 new file mode 100644 index 00000000..d1ad6350 --- /dev/null +++ b/man/man3/tomo-Table.has.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Table.has 3 2025-04-19T14:30:40.366893 "Tomo man-pages" +.SH NAME +Table.has \- Checks if the table contains a specified key. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Table.has : func(t: {K=V}, key: K -> Bool)" +.fi + +.SH DESCRIPTION +Checks if the table contains a specified key. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +t {K=V} The table. - +key K The key to check for presence. - +.TE +.SH RETURN +`yes` if the key is present, `no` otherwise. + +.SH EXAMPLES +.EX +>> {"A"=1, "B"=2}.has("A") += yes +>> {"A"=1, "B"=2}.has("xxx") += no +.EE diff --git a/man/man3/tomo-Table.remove.3 b/man/man3/tomo-Table.remove.3 new file mode 100644 index 00000000..2ea6e833 --- /dev/null +++ b/man/man3/tomo-Table.remove.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Table.remove 3 2025-04-19T14:30:40.366935 "Tomo man-pages" +.SH NAME +Table.remove \- Removes the key-value pair associated with a specified key. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Table.remove : func(t: {K=V}, key: K -> Void)" +.fi + +.SH DESCRIPTION +Removes the key-value pair associated with a specified key. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +t {K=V} The reference to the table. - +key K The key of the key-value pair to remove. - +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +t := {"A"=1, "B"=2} +t.remove("A") +>> t += {"B"=2} +.EE diff --git a/man/man3/tomo-Table.set.3 b/man/man3/tomo-Table.set.3 new file mode 100644 index 00000000..86646f42 --- /dev/null +++ b/man/man3/tomo-Table.set.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Table.set 3 2025-04-19T14:30:40.366976 "Tomo man-pages" +.SH NAME +Table.set \- Sets or updates the value associated with a specified key. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Table.set : func(t: {K=V}, key: K, value: V -> Void)" +.fi + +.SH DESCRIPTION +Sets or updates the value associated with a specified key. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +t {K=V} The reference to the table. - +key K The key to set or update. - +value V The value to associate with the key. - +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +t := {"A"=1, "B"=2} +t.set("C", 3) +>> t += {"A"=1, "B"=2, "C"=3} +.EE diff --git a/man/man3/tomo-Text.as_c_string.3 b/man/man3/tomo-Text.as_c_string.3 new file mode 100644 index 00000000..9933b17a --- /dev/null +++ b/man/man3/tomo-Text.as_c_string.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.as_c_string 3 2025-04-19T14:30:40.367014 "Tomo man-pages" +.SH NAME +Text.as_c_string \- Converts a `Text` value to a C-style string. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.as_c_string : func(text: Text -> CString)" +.fi + +.SH DESCRIPTION +Converts a `Text` value to a C-style string. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be converted to a C-style string. - +.TE +.SH RETURN +A C-style string (`CString`) representing the text. + +.SH EXAMPLES +.EX +>> "Hello".as_c_string() += CString("Hello") +.EE diff --git a/man/man3/tomo-Text.at.3 b/man/man3/tomo-Text.at.3 new file mode 100644 index 00000000..50693494 --- /dev/null +++ b/man/man3/tomo-Text.at.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.at 3 2025-04-19T14:30:40.367051 "Tomo man-pages" +.SH NAME +Text.at \- Get the graphical cluster at a given index. This is similar to `str[i]` with ASCII text, but has more correct behavior for unicode text. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.at : func(text: Text, index: Int -> Text)" +.fi + +.SH DESCRIPTION +Get the graphical cluster at a given index. This is similar to `str[i]` with ASCII text, but has more correct behavior for unicode text. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text from which to get a cluster. - +index Int The index of the graphical cluster (1-indexed). - +.TE +.SH RETURN +A `Text` with the single graphical cluster at the given index. Note: negative indices are counted from the back of the text, so `-1` means the last cluster, `-2` means the second-to-last, and so on. + +.SH EXAMPLES +.EX +>> "Amélie".at(3) += "é" +.EE diff --git a/man/man3/tomo-Text.by_line.3 b/man/man3/tomo-Text.by_line.3 new file mode 100644 index 00000000..a5066e66 --- /dev/null +++ b/man/man3/tomo-Text.by_line.3 @@ -0,0 +1,39 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.by_line 3 2025-04-19T14:30:40.367111 "Tomo man-pages" +.SH NAME +Text.by_line \- Returns an iterator function that can be used to iterate over the lines in a text. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.by_line : func(text: Text -> func(->Text?))" +.fi + +.SH DESCRIPTION +Returns an iterator function that can be used to iterate over the lines in a text. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be iterated over, line by line. - +.TE +.SH RETURN +An iterator function that returns one line at a time, until it runs out and returns `none`. **Note:** this function ignores a trailing newline if there is one. If you don't want this behavior, use `text.by_split($/{1 nl}/)` instead. + +.SH EXAMPLES +.EX +text := " +line one +line two +" +for line in text.by_line() +# Prints: "line one" then "line two": +say(line) +.EE diff --git a/man/man3/tomo-Text.by_split.3 b/man/man3/tomo-Text.by_split.3 new file mode 100644 index 00000000..ad585f50 --- /dev/null +++ b/man/man3/tomo-Text.by_split.3 @@ -0,0 +1,40 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.by_split 3 2025-04-19T14:30:40.367152 "Tomo man-pages" +.SH NAME +Text.by_split \- Returns an iterator function that can be used to iterate over text separated by a delimiter. **Note:** to split based on a set of delimiters, use [`by_split_any()`](#by_split_any). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.by_split : func(text: Text, delimiter: Text = "" -> func(->Text?))" +.fi + +.SH DESCRIPTION +Returns an iterator function that can be used to iterate over text separated by a delimiter. **Note:** to split based on a set of delimiters, use [`by_split_any()`](#by_split_any). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be iterated over in delimited chunks. - +delimiter Text An exact delimiter to use for splitting the text. "" +.TE +.SH RETURN +An iterator function that returns one chunk of text at a time, separated by the given delimiter, until it runs out and returns `none`. **Note:** using an empty delimiter (the default) will iterate over single grapheme clusters in the text. + +.SH NOTES +If an empty text is given as the delimiter, then each split will be the graphical clusters of the text. + +.SH EXAMPLES +.EX +text := "one,two,three" +for chunk in text.by_split(",") +# Prints: "one" then "two" then "three": +say(chunk) +.EE diff --git a/man/man3/tomo-Text.by_split_any.3 b/man/man3/tomo-Text.by_split_any.3 new file mode 100644 index 00000000..e7b361f1 --- /dev/null +++ b/man/man3/tomo-Text.by_split_any.3 @@ -0,0 +1,40 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.by_split_any 3 2025-04-19T14:30:40.367193 "Tomo man-pages" +.SH NAME +Text.by_split_any \- Returns an iterator function that can be used to iterate over text separated by one or more characters (grapheme clusters) from a given text of delimiters. **Note:** to split based on an exact delimiter, use [`by_split()`](#by_split). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.by_split_any : func(text: Text, delimiters: Text = " $\\t\\r\\n" -> func(->Text?))" +.fi + +.SH DESCRIPTION +Returns an iterator function that can be used to iterate over text separated by one or more characters (grapheme clusters) from a given text of delimiters. **Note:** to split based on an exact delimiter, use [`by_split()`](#by_split). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be iterated over in delimited chunks. - +delimiters Text Grapheme clusters to use for splitting the text. " $\\t\\r\\n" +.TE +.SH RETURN +An iterator function that returns one chunk of text at a time, separated by the given delimiter characters, until it runs out and returns `none`. + +.SH NOTES +Splitting will occur on every place where one or more of the grapheme clusters in `delimiters` occurs. + +.SH EXAMPLES +.EX +text := "one,two,;,three" +for chunk in text.by_split_any(",;") +# Prints: "one" then "two" then "three": +say(chunk) +.EE diff --git a/man/man3/tomo-Text.bytes.3 b/man/man3/tomo-Text.bytes.3 new file mode 100644 index 00000000..3f45e6a7 --- /dev/null +++ b/man/man3/tomo-Text.bytes.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.bytes 3 2025-04-19T14:30:40.367234 "Tomo man-pages" +.SH NAME +Text.bytes \- Converts a `Text` value to a list of bytes representing a UTF8 encoding of the text. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.bytes : func(text: Text -> [Byte])" +.fi + +.SH DESCRIPTION +Converts a `Text` value to a list of bytes representing a UTF8 encoding of the text. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be converted to UTF8 bytes. - +.TE +.SH RETURN +A list of bytes (`[Byte]`) representing the text in UTF8 encoding. + +.SH EXAMPLES +.EX +>> "Amélie".bytes() += [65, 109, 195, 169, 108, 105, 101] +.EE diff --git a/man/man3/tomo-Text.caseless_equals.3 b/man/man3/tomo-Text.caseless_equals.3 new file mode 100644 index 00000000..e202bd22 --- /dev/null +++ b/man/man3/tomo-Text.caseless_equals.3 @@ -0,0 +1,40 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.caseless_equals 3 2025-04-19T14:30:40.367273 "Tomo man-pages" +.SH NAME +Text.caseless_equals \- Checks whether two texts are equal, ignoring the casing of the letters (i.e. case-insensitive comparison). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.caseless_equals : func(a: Text, b: Text, language: Text = "C" -> Bool)" +.fi + +.SH DESCRIPTION +Checks whether two texts are equal, ignoring the casing of the letters (i.e. case-insensitive comparison). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +a Text The first text to compare case-insensitively. - +b Text The second text to compare case-insensitively. - +language Text The ISO 639 language code for which casing rules to use. "C" +.TE +.SH RETURN +`yes` if `a` and `b` are equal to each other, ignoring casing, otherwise `no`. + +.SH EXAMPLES +.EX +>> "A".caseless_equals("a") += yes + +# Turkish lowercase "I" is "ı" (dotless I), not "i" +>> "I".caseless_equals("i", language="tr_TR") += no +.EE diff --git a/man/man3/tomo-Text.codepoint_names.3 b/man/man3/tomo-Text.codepoint_names.3 new file mode 100644 index 00000000..b33f5a86 --- /dev/null +++ b/man/man3/tomo-Text.codepoint_names.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.codepoint_names 3 2025-04-19T14:30:40.367316 "Tomo man-pages" +.SH NAME +Text.codepoint_names \- Returns a list of the names of each codepoint in the text. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.codepoint_names : func(text: Text -> [Text])" +.fi + +.SH DESCRIPTION +Returns a list of the names of each codepoint in the text. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text from which to extract codepoint names. - +.TE +.SH RETURN +A list of codepoint names (`[Text]`). + +.SH EXAMPLES +.EX +>> "Amélie".codepoint_names() += ["LATIN CAPITAL LETTER A", "LATIN SMALL LETTER M", "LATIN SMALL LETTER E WITH ACUTE", "LATIN SMALL LETTER L", "LATIN SMALL LETTER I", "LATIN SMALL LETTER E"] +.EE diff --git a/man/man3/tomo-Text.ends_with.3 b/man/man3/tomo-Text.ends_with.3 new file mode 100644 index 00000000..cb991cc2 --- /dev/null +++ b/man/man3/tomo-Text.ends_with.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.ends_with 3 2025-04-19T14:30:40.367353 "Tomo man-pages" +.SH NAME +Text.ends_with \- Checks if the `Text` ends with a literal suffix text. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.ends_with : func(text: Text, suffix: Text -> Bool)" +.fi + +.SH DESCRIPTION +Checks if the `Text` ends with a literal suffix text. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be searched. - +suffix Text The literal suffix text to check for. - +.TE +.SH RETURN +`yes` if the text has the target, `no` otherwise. + +.SH EXAMPLES +.EX +>> "hello world".ends_with("world") += yes +.EE diff --git a/man/man3/tomo-Text.from.3 b/man/man3/tomo-Text.from.3 new file mode 100644 index 00000000..caf232e5 --- /dev/null +++ b/man/man3/tomo-Text.from.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.from 3 2025-04-19T14:30:40.367391 "Tomo man-pages" +.SH NAME +Text.from \- Get a slice of the text, starting at the given position. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.from : func(text: Text, first: Int -> Text)" +.fi + +.SH DESCRIPTION +Get a slice of the text, starting at the given position. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be sliced. - +first Int The index to begin the slice. - +.TE +.SH RETURN +The text from the given grapheme cluster to the end of the text. Note: a negative index counts backwards from the end of the text, so `-1` refers to the last cluster, `-2` the second-to-last, etc. Slice ranges will be truncated to the length of the text. + +.SH EXAMPLES +.EX +>> "hello".from(2) += "ello" + +>> "hello".from(-2) += "lo" +.EE diff --git a/man/man3/tomo-Text.from_bytes.3 b/man/man3/tomo-Text.from_bytes.3 new file mode 100644 index 00000000..2bcdccfb --- /dev/null +++ b/man/man3/tomo-Text.from_bytes.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.from_bytes 3 2025-04-19T14:30:40.367429 "Tomo man-pages" +.SH NAME +Text.from_bytes \- Returns text that has been constructed from the given UTF8 bytes. Note: the text will be normalized, so the resulting text's UTF8 bytes may not exactly match the input. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.from_bytes : func(bytes: [Byte] -> [Text])" +.fi + +.SH DESCRIPTION +Returns text that has been constructed from the given UTF8 bytes. Note: the text will be normalized, so the resulting text's UTF8 bytes may not exactly match the input. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +bytes [Byte] The UTF-8 bytes of the desired text. - +.TE +.SH RETURN +A new text based on the input UTF8 bytes after normalization has been applied. + +.SH EXAMPLES +.EX +>> Text.from_bytes([195, 133, 107, 101]) += "Åke" +.EE diff --git a/man/man3/tomo-Text.from_c_string.3 b/man/man3/tomo-Text.from_c_string.3 new file mode 100644 index 00000000..99cbb233 --- /dev/null +++ b/man/man3/tomo-Text.from_c_string.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.from_c_string 3 2025-04-19T14:30:40.367465 "Tomo man-pages" +.SH NAME +Text.from_c_string \- Converts a C-style string to a `Text` value. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.from_c_string : func(str: CString -> Text)" +.fi + +.SH DESCRIPTION +Converts a C-style string to a `Text` value. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +str CString The C-style string to be converted. - +.TE +.SH RETURN +A `Text` value representing the C-style string. + +.SH EXAMPLES +.EX +>> Text.from_c_string(CString("Hello")) += "Hello" +.EE diff --git a/man/man3/tomo-Text.from_codepoint_names.3 b/man/man3/tomo-Text.from_codepoint_names.3 new file mode 100644 index 00000000..2d0dd186 --- /dev/null +++ b/man/man3/tomo-Text.from_codepoint_names.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.from_codepoint_names 3 2025-04-19T14:30:40.367510 "Tomo man-pages" +.SH NAME +Text.from_codepoint_names \- Returns text that has the given codepoint names (according to the Unicode specification) as its codepoints. Note: the text will be normalized, so the resulting text's codepoints may not exactly match the input codepoints. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.from_codepoint_names : func(codepoint_names: [Text] -> [Text])" +.fi + +.SH DESCRIPTION +Returns text that has the given codepoint names (according to the Unicode specification) as its codepoints. Note: the text will be normalized, so the resulting text's codepoints may not exactly match the input codepoints. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +codepoint_names [Text] The names of each codepoint in the desired text (case-insentive). - +.TE +.SH RETURN +A new text with the specified codepoints after normalization has been applied. Any invalid names are ignored. + +.SH EXAMPLES +.EX +>> Text.from_codepoint_names([ +"LATIN CAPITAL LETTER A WITH RING ABOVE", +"LATIN SMALL LETTER K", +"LATIN SMALL LETTER E", +] += "Åke" +.EE diff --git a/man/man3/tomo-Text.from_codepoints.3 b/man/man3/tomo-Text.from_codepoints.3 new file mode 100644 index 00000000..7bcb72cb --- /dev/null +++ b/man/man3/tomo-Text.from_codepoints.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.from_codepoints 3 2025-04-19T14:30:40.367551 "Tomo man-pages" +.SH NAME +Text.from_codepoints \- Returns text that has been constructed from the given UTF32 codepoints. Note: the text will be normalized, so the resulting text's codepoints may not exactly match the input codepoints. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.from_codepoints : func(codepoints: [Int32] -> [Text])" +.fi + +.SH DESCRIPTION +Returns text that has been constructed from the given UTF32 codepoints. Note: the text will be normalized, so the resulting text's codepoints may not exactly match the input codepoints. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +codepoints [Int32] The UTF32 codepoints in the desired text. - +.TE +.SH RETURN +A new text with the specified codepoints after normalization has been applied. + +.SH EXAMPLES +.EX +>> Text.from_codepoints([197, 107, 101]) += "Åke" +.EE diff --git a/man/man3/tomo-Text.has.3 b/man/man3/tomo-Text.has.3 new file mode 100644 index 00000000..7cd8564d --- /dev/null +++ b/man/man3/tomo-Text.has.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.has 3 2025-04-19T14:30:40.367609 "Tomo man-pages" +.SH NAME +Text.has \- Checks if the `Text` contains some target text. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.has : func(text: Text, target: Text -> Bool)" +.fi + +.SH DESCRIPTION +Checks if the `Text` contains some target text. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be searched. - +target Text The text to search for. - +.TE +.SH RETURN +`yes` if the target text is found, `no` otherwise. + +.SH EXAMPLES +.EX +>> "hello world".has("wo") += yes +>> "hello world".has("xxx") += no +.EE diff --git a/man/man3/tomo-Text.join.3 b/man/man3/tomo-Text.join.3 new file mode 100644 index 00000000..e98390a0 --- /dev/null +++ b/man/man3/tomo-Text.join.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.join 3 2025-04-19T14:30:40.367649 "Tomo man-pages" +.SH NAME +Text.join \- Joins a list of text pieces with a specified glue. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.join : func(glue: Text, pieces: [Text] -> Text)" +.fi + +.SH DESCRIPTION +Joins a list of text pieces with a specified glue. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +glue Text The text used to join the pieces. - +pieces [Text] The list of text pieces to be joined. - +.TE +.SH RETURN +A single `Text` value with the pieces joined by the glue. + +.SH EXAMPLES +.EX +>> ", ".join(["one", "two", "three"]) += "one, two, three" +.EE diff --git a/man/man3/tomo-Text.left_pad.3 b/man/man3/tomo-Text.left_pad.3 new file mode 100644 index 00000000..c8e25cf8 --- /dev/null +++ b/man/man3/tomo-Text.left_pad.3 @@ -0,0 +1,39 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.left_pad 3 2025-04-19T14:30:40.367729 "Tomo man-pages" +.SH NAME +Text.left_pad \- Pad some text on the left side so it reaches a target width. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.left_pad : func(text: Text, width: Int, pad: Text = " ", language: Text = "C" -> Text)" +.fi + +.SH DESCRIPTION +Pad some text on the left side so it reaches a target width. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to pad. - +width Int The target width. - +pad Text The padding text. " " +language Text The ISO 639 language code for which character width to use. "C" +.TE +.SH RETURN +Text with length at least `width`, with extra padding on the left as needed. If `pad` has length greater than 1, it may be partially repeated to reach the exact desired length. + +.SH EXAMPLES +.EX +>> "x".left_pad(5) += " x" +>> "x".left_pad(5, "ABC") += "ABCAx" +.EE diff --git a/man/man3/tomo-Text.lines.3 b/man/man3/tomo-Text.lines.3 new file mode 100644 index 00000000..78ecf7dc --- /dev/null +++ b/man/man3/tomo-Text.lines.3 @@ -0,0 +1,42 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.lines 3 2025-04-19T14:30:40.367769 "Tomo man-pages" +.SH NAME +Text.lines \- Splits the text into a list of lines of text, preserving blank lines, ignoring trailing newlines, and handling `\r\n` the same as `\n`. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.lines : func(text: Text -> [Text])" +.fi + +.SH DESCRIPTION +Splits the text into a list of lines of text, preserving blank lines, ignoring trailing newlines, and handling `\r\n` the same as `\n`. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be split into lines. - +.TE +.SH RETURN +A list of substrings resulting from the split. + +.SH EXAMPLES +.EX +>> "one\\ntwo\\nthree".lines() += ["one", "two", "three"] +>> "one\\ntwo\\nthree\\n".lines() += ["one", "two", "three"] +>> "one\\ntwo\\nthree\\n\\n".lines() += ["one", "two", "three", ""] +>> "one\\r\\ntwo\\r\\nthree\\r\\n".lines() += ["one", "two", "three"] +>> "".lines() += [] +.EE diff --git a/man/man3/tomo-Text.lower.3 b/man/man3/tomo-Text.lower.3 new file mode 100644 index 00000000..9d9251bb --- /dev/null +++ b/man/man3/tomo-Text.lower.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.lower 3 2025-04-19T14:30:40.367810 "Tomo man-pages" +.SH NAME +Text.lower \- Converts all characters in the text to lowercase. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.lower : func(text: Text, language: Text = "C" -> Text)" +.fi + +.SH DESCRIPTION +Converts all characters in the text to lowercase. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be converted to lowercase. - +language Text The ISO 639 language code for which casing rules to use. "C" +.TE +.SH RETURN +The lowercase version of the text. + +.SH EXAMPLES +.EX +>> "AMÉLIE".lower() += "amélie" + +>> "I".lower(language="tr_TR") +>> "ı" +.EE diff --git a/man/man3/tomo-Text.middle_pad.3 b/man/man3/tomo-Text.middle_pad.3 new file mode 100644 index 00000000..84600daa --- /dev/null +++ b/man/man3/tomo-Text.middle_pad.3 @@ -0,0 +1,39 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.middle_pad 3 2025-04-19T14:30:40.367688 "Tomo man-pages" +.SH NAME +Text.middle_pad \- Pad some text on the left and right side so it reaches a target width. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.middle_pad : func(text: Text, width: Int, pad: Text = " ", language: Text = "C" -> Text)" +.fi + +.SH DESCRIPTION +Pad some text on the left and right side so it reaches a target width. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to pad. - +width Int The target width. - +pad Text The padding text. " " +language Text The ISO 639 language code for which character width to use. "C" +.TE +.SH RETURN +Text with length at least `width`, with extra padding on the left and right as needed. If `pad` has length greater than 1, it may be partially repeated to reach the exact desired length. + +.SH EXAMPLES +.EX +>> "x".middle_pad(6) += " x " +>> "x".middle_pad(10, "ABC") += "ABCAxABCAB" +.EE diff --git a/man/man3/tomo-Text.quoted.3 b/man/man3/tomo-Text.quoted.3 new file mode 100644 index 00000000..08f14d2f --- /dev/null +++ b/man/man3/tomo-Text.quoted.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.quoted 3 2025-04-19T14:30:40.367849 "Tomo man-pages" +.SH NAME +Text.quoted \- Formats the text with quotation marks and escapes. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.quoted : func(text: Text, color: Bool = no, quotation_mark: Text = `"` -> Text)" +.fi + +.SH DESCRIPTION +Formats the text with quotation marks and escapes. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be quoted. - +color Bool Whether to add color formatting. no +quotation_mark Text The quotation mark to use. `"` +.TE +.SH RETURN +The text formatted as a quoted text. + +.SH EXAMPLES +.EX +>> "one\\ntwo".quoted() += "\\"one\\\\ntwo\\"" +.EE diff --git a/man/man3/tomo-Text.repeat.3 b/man/man3/tomo-Text.repeat.3 new file mode 100644 index 00000000..8dd62806 --- /dev/null +++ b/man/man3/tomo-Text.repeat.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.repeat 3 2025-04-19T14:30:40.367888 "Tomo man-pages" +.SH NAME +Text.repeat \- Repeat some text multiple times. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.repeat : func(text: Text, count: Int -> Text)" +.fi + +.SH DESCRIPTION +Repeat some text multiple times. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to repeat. - +count Int The number of times to repeat it. (Negative numbers are equivalent to zero). - +.TE +.SH RETURN +The text repeated the given number of times. + +.SH EXAMPLES +.EX +>> "Abc".repeat(3) += "AbcAbcAbc" +.EE diff --git a/man/man3/tomo-Text.replace.3 b/man/man3/tomo-Text.replace.3 new file mode 100644 index 00000000..4b7993fc --- /dev/null +++ b/man/man3/tomo-Text.replace.3 @@ -0,0 +1,36 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.replace 3 2025-04-19T14:30:40.367925 "Tomo man-pages" +.SH NAME +Text.replace \- Replaces occurrences of a target text with a replacement text. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.replace : func(text: Text, target: Text, replacement: Text -> Text)" +.fi + +.SH DESCRIPTION +Replaces occurrences of a target text with a replacement text. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text in which to perform replacements. - +target Text The target text to be replaced. - +replacement Text The text to replace the target with. - +.TE +.SH RETURN +The text with occurrences of the target replaced. + +.SH EXAMPLES +.EX +>> "Hello world".replace("world", "there") += "Hello there" +.EE diff --git a/man/man3/tomo-Text.reversed.3 b/man/man3/tomo-Text.reversed.3 new file mode 100644 index 00000000..6966877b --- /dev/null +++ b/man/man3/tomo-Text.reversed.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.reversed 3 2025-04-19T14:30:40.367963 "Tomo man-pages" +.SH NAME +Text.reversed \- Return a text that has the grapheme clusters in reverse order. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.reversed : func(text: Text -> Text)" +.fi + +.SH DESCRIPTION +Return a text that has the grapheme clusters in reverse order. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to reverse. - +.TE +.SH RETURN +A reversed version of the text. + +.SH EXAMPLES +.EX +>> "Abc".reversed() += "cbA" +.EE diff --git a/man/man3/tomo-Text.right_pad.3 b/man/man3/tomo-Text.right_pad.3 new file mode 100644 index 00000000..3fc5b404 --- /dev/null +++ b/man/man3/tomo-Text.right_pad.3 @@ -0,0 +1,39 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.right_pad 3 2025-04-19T14:30:40.367999 "Tomo man-pages" +.SH NAME +Text.right_pad \- Pad some text on the right side so it reaches a target width. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.right_pad : func(text: Text, width: Int, pad: Text = " ", language: Text = "C" -> Text)" +.fi + +.SH DESCRIPTION +Pad some text on the right side so it reaches a target width. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to pad. - +width Int The target width. - +pad Text The padding text. " " +language Text The ISO 639 language code for which character width to use. "C" +.TE +.SH RETURN +Text with length at least `width`, with extra padding on the right as needed. If `pad` has length greater than 1, it may be partially repeated to reach the exact desired length. + +.SH EXAMPLES +.EX +>> "x".right_pad(5) += "x " +>> "x".right_pad(5, "ABC") += "xABCA" +.EE diff --git a/man/man3/tomo-Text.slice.3 b/man/man3/tomo-Text.slice.3 new file mode 100644 index 00000000..8c4cd9f0 --- /dev/null +++ b/man/man3/tomo-Text.slice.3 @@ -0,0 +1,42 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.slice 3 2025-04-19T14:30:40.368043 "Tomo man-pages" +.SH NAME +Text.slice \- Get a slice of the text. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.slice : func(text: Text, from: Int = 1, to: Int = -1 -> Text)" +.fi + +.SH DESCRIPTION +Get a slice of the text. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be sliced. - +from Int The index of the first grapheme cluster to include (1-indexed). 1 +to Int The index of the last grapheme cluster to include (1-indexed). -1 +.TE +.SH RETURN +The text that spans the given grapheme cluster indices. Note: a negative index counts backwards from the end of the text, so `-1` refers to the last cluster, `-2` the second-to-last, etc. Slice ranges will be truncated to the length of the text. + +.SH EXAMPLES +.EX +>> "hello".slice(2, 3) += "el" + +>> "hello".slice(to=-2) += "hell" + +>> "hello".slice(from=2) += "ello" +.EE diff --git a/man/man3/tomo-Text.split.3 b/man/man3/tomo-Text.split.3 new file mode 100644 index 00000000..5c6bf034 --- /dev/null +++ b/man/man3/tomo-Text.split.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.split 3 2025-04-19T14:30:40.368084 "Tomo man-pages" +.SH NAME +Text.split \- Splits the text into a list of substrings based on exact matches of a delimiter. **Note:** to split based on a set of delimiter characters, use [`split_any()`](#split_any). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.split : func(text: Text, delimiter: Text = "" -> [Text])" +.fi + +.SH DESCRIPTION +Splits the text into a list of substrings based on exact matches of a delimiter. **Note:** to split based on a set of delimiter characters, use [`split_any()`](#split_any). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be split. - +delimiter Text The delimiter used to split the text. If the delimiter is the empty text, the text will be split into individual grapheme clusters. "" +.TE +.SH RETURN +A list of subtexts resulting from the split. + +.SH EXAMPLES +.EX +>> "one,two,,three".split(",") += ["one", "two", "", "three"] + +>> "abc".split() += ["a", "b", "c"] +.EE diff --git a/man/man3/tomo-Text.split_any.3 b/man/man3/tomo-Text.split_any.3 new file mode 100644 index 00000000..dc91b796 --- /dev/null +++ b/man/man3/tomo-Text.split_any.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.split_any 3 2025-04-19T14:30:40.368129 "Tomo man-pages" +.SH NAME +Text.split_any \- Splits the text into a list of substrings at one or more occurrences of a set of delimiter characters (grapheme clusters). **Note:** to split based on an exact delimiter, use [`split()`](#split). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.split_any : func(text: Text, delimiters: Text = " $\\t\\r\\n" -> [Text])" +.fi + +.SH DESCRIPTION +Splits the text into a list of substrings at one or more occurrences of a set of delimiter characters (grapheme clusters). **Note:** to split based on an exact delimiter, use [`split()`](#split). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be split. - +delimiters Text A text containing multiple delimiters to be used for splitting the text into chunks. " $\\t\\r\\n" +.TE +.SH RETURN +A list of subtexts resulting from the split. + +.SH EXAMPLES +.EX +>> "one, two,,three".split_any(", ") += ["one", "two", "three"] +.EE diff --git a/man/man3/tomo-Text.starts_with.3 b/man/man3/tomo-Text.starts_with.3 new file mode 100644 index 00000000..7f3d3bd8 --- /dev/null +++ b/man/man3/tomo-Text.starts_with.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.starts_with 3 2025-04-19T14:30:40.368184 "Tomo man-pages" +.SH NAME +Text.starts_with \- Checks if the `Text` starts with a literal prefix text. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.starts_with : func(text: Text, prefix: Text -> Bool)" +.fi + +.SH DESCRIPTION +Checks if the `Text` starts with a literal prefix text. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be searched. - +prefix Text The literal prefix text to check for. - +.TE +.SH RETURN +`yes` if the text has the given prefix, `no` otherwise. + +.SH EXAMPLES +.EX +>> "hello world".starts_with("hello") += yes +.EE diff --git a/man/man3/tomo-Text.title.3 b/man/man3/tomo-Text.title.3 new file mode 100644 index 00000000..0204d2ad --- /dev/null +++ b/man/man3/tomo-Text.title.3 @@ -0,0 +1,39 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.title 3 2025-04-19T14:30:40.368227 "Tomo man-pages" +.SH NAME +Text.title \- Converts the text to title case (capitalizing the first letter of each word). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.title : func(text: Text, language: Text = "C" -> Text)" +.fi + +.SH DESCRIPTION +Converts the text to title case (capitalizing the first letter of each word). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be converted to title case. - +language Text The ISO 639 language code for which casing rules to use. "C" +.TE +.SH RETURN +The text in title case. + +.SH EXAMPLES +.EX +>> "amélie".title() += "Amélie" + +# In Turkish, uppercase "i" is "İ" +>> "i".title(language="tr_TR") += "İ" +.EE diff --git a/man/man3/tomo-Text.to.3 b/man/man3/tomo-Text.to.3 new file mode 100644 index 00000000..bc95fa9e --- /dev/null +++ b/man/man3/tomo-Text.to.3 @@ -0,0 +1,38 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.to 3 2025-04-19T14:30:40.368269 "Tomo man-pages" +.SH NAME +Text.to \- Get a slice of the text, ending at the given position. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.to : func(text: Text, last: Int -> Text)" +.fi + +.SH DESCRIPTION +Get a slice of the text, ending at the given position. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be sliced. - +last Int The index of the last grapheme cluster to include (1-indexed). - +.TE +.SH RETURN +The text up to and including the given grapheme cluster. Note: a negative index counts backwards from the end of the text, so `-1` refers to the last cluster, `-2` the second-to-last, etc. Slice ranges will be truncated to the length of the text. + +.SH EXAMPLES +.EX +>> "goodbye".to(3) += "goo" + +>> "goodbye".to(-2) += "goodby" +.EE diff --git a/man/man3/tomo-Text.translate.3 b/man/man3/tomo-Text.translate.3 new file mode 100644 index 00000000..eaca1312 --- /dev/null +++ b/man/man3/tomo-Text.translate.3 @@ -0,0 +1,40 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.translate 3 2025-04-19T14:30:40.368308 "Tomo man-pages" +.SH NAME +Text.translate \- Takes a table mapping target texts to their replacements and performs all the replacements in the table on the whole text. At each position, the first matching replacement is applied and the matching moves on to *after* the replacement text, so replacement text is not recursively modified. See [`replace()`](#replace) for more information about replacement behavior. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.translate : func(translations: {Text=Text} -> Text)" +.fi + +.SH DESCRIPTION +Takes a table mapping target texts to their replacements and performs all the replacements in the table on the whole text. At each position, the first matching replacement is applied and the matching moves on to *after* the replacement text, so replacement text is not recursively modified. See [`replace()`](#replace) for more information about replacement behavior. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +translations {Text=Text} A table mapping from target text to its replacement. - +.TE +.SH RETURN +The text with all occurrences of the targets replaced with their corresponding replacement text. + +.SH EXAMPLES +.EX +>> "A <tag> & an amperand".translate({ +"&" = "&", +"<" = "<", +">" = ">", +\&'"" = """, +"'" = "'", +} += "A <tag> & an ampersand" +.EE diff --git a/man/man3/tomo-Text.trim.3 b/man/man3/tomo-Text.trim.3 new file mode 100644 index 00000000..2c927630 --- /dev/null +++ b/man/man3/tomo-Text.trim.3 @@ -0,0 +1,43 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.trim 3 2025-04-19T14:30:40.368347 "Tomo man-pages" +.SH NAME +Text.trim \- Trims the given characters (grapheme clusters) from the left and/or right side of the text. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.trim : func(text: Text, to_trim: Text = " $\\t\\r\\n", left: Bool = yes, right: Bool = yes -> Text)" +.fi + +.SH DESCRIPTION +Trims the given characters (grapheme clusters) from the left and/or right side of the text. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be trimmed. - +to_trim Text The characters to remove from the left/right of the text. " $\\t\\r\\n" +left Bool Whether or not to trim from the front of the text. yes +right Bool Whether or not to trim from the back of the text. yes +.TE +.SH RETURN +The text without the trim characters at either end. + +.SH EXAMPLES +.EX +>> " x y z \\n".trim() += "x y z" + +>> "one,".trim(",") += "one" + +>> " xyz ".trim(right=no) += "xyz " +.EE diff --git a/man/man3/tomo-Text.upper.3 b/man/man3/tomo-Text.upper.3 new file mode 100644 index 00000000..b6602765 --- /dev/null +++ b/man/man3/tomo-Text.upper.3 @@ -0,0 +1,39 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.upper 3 2025-04-19T14:30:40.368388 "Tomo man-pages" +.SH NAME +Text.upper \- Converts all characters in the text to uppercase. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.upper : func(text: Text, language: Text = "C" -> Text)" +.fi + +.SH DESCRIPTION +Converts all characters in the text to uppercase. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to be converted to uppercase. - +language Text The ISO 639 language code for which casing rules to use. "C" +.TE +.SH RETURN +The uppercase version of the text. + +.SH EXAMPLES +.EX +>> "amélie".upper() += "AMÉLIE" + +# In Turkish, uppercase "i" is "İ" +>> "i".upper(language="tr_TR") += "İ" +.EE diff --git a/man/man3/tomo-Text.utf32_codepoints.3 b/man/man3/tomo-Text.utf32_codepoints.3 new file mode 100644 index 00000000..2ceb620b --- /dev/null +++ b/man/man3/tomo-Text.utf32_codepoints.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.utf32_codepoints 3 2025-04-19T14:30:40.368427 "Tomo man-pages" +.SH NAME +Text.utf32_codepoints \- Returns a list of Unicode code points for UTF32 encoding of the text. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.utf32_codepoints : func(text: Text -> [Int32])" +.fi + +.SH DESCRIPTION +Returns a list of Unicode code points for UTF32 encoding of the text. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text from which to extract Unicode code points. - +.TE +.SH RETURN +A list of 32-bit integer Unicode code points (`[Int32]`). + +.SH EXAMPLES +.EX +>> "Amélie".utf32_codepoints() += [65, 109, 233, 108, 105, 101] +.EE diff --git a/man/man3/tomo-Text.width.3 b/man/man3/tomo-Text.width.3 new file mode 100644 index 00000000..46b29fee --- /dev/null +++ b/man/man3/tomo-Text.width.3 @@ -0,0 +1,39 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.width 3 2025-04-19T14:30:40.368465 "Tomo man-pages" +.SH NAME +Text.width \- Returns the display width of the text as seen in a terminal with appropriate font rendering. This is usually the same as the text's `.length`, but there are some characters like emojis that render wider than 1 cell. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.width : func(text: Text -> Int)" +.fi + +.SH DESCRIPTION +Returns the display width of the text as seen in a terminal with appropriate font rendering. This is usually the same as the text's `.length`, but there are some characters like emojis that render wider than 1 cell. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text whose length you want. - +.TE +.SH RETURN +An integer representing the display width of the text. + +.SH NOTES +This will not always be exactly accurate when your terminal's font rendering can't handle some unicode displaying correctly. + +.SH EXAMPLES +.EX +>> "Amélie".width() += 6 +>> "🤠".width() += 2 +.EE diff --git a/man/man3/tomo-Text.without_prefix.3 b/man/man3/tomo-Text.without_prefix.3 new file mode 100644 index 00000000..1ed3f644 --- /dev/null +++ b/man/man3/tomo-Text.without_prefix.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.without_prefix 3 2025-04-19T14:30:40.368531 "Tomo man-pages" +.SH NAME +Text.without_prefix \- Returns the text with a given prefix removed (if present). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.without_prefix : func(text: Text, prefix: Text -> Text)" +.fi + +.SH DESCRIPTION +Returns the text with a given prefix removed (if present). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to remove the prefix from. - +prefix Text The prefix to remove. - +.TE +.SH RETURN +A text without the given prefix (if present) or the unmodified text if the prefix is not present. + +.SH EXAMPLES +.EX +>> "foo:baz".without_prefix("foo:") += "baz" +>> "qux".without_prefix("foo:") += "qux" +.EE diff --git a/man/man3/tomo-Text.without_suffix.3 b/man/man3/tomo-Text.without_suffix.3 new file mode 100644 index 00000000..710e7852 --- /dev/null +++ b/man/man3/tomo-Text.without_suffix.3 @@ -0,0 +1,37 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH Text.without_suffix 3 2025-04-19T14:30:40.368570 "Tomo man-pages" +.SH NAME +Text.without_suffix \- Returns the text with a given suffix removed (if present). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "Text.without_suffix : func(text: Text, suffix: Text -> Text)" +.fi + +.SH DESCRIPTION +Returns the text with a given suffix removed (if present). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to remove the suffix from. - +suffix Text The suffix to remove. - +.TE +.SH RETURN +A text without the given suffix (if present) or the unmodified text if the suffix is not present. + +.SH EXAMPLES +.EX +>> "baz.foo".without_suffix(".foo") += "baz" +>> "qux".without_suffix(".foo") += "qux" +.EE diff --git a/man/man3/tomo-USE_COLOR.3 b/man/man3/tomo-USE_COLOR.3 new file mode 100644 index 00000000..fdad34a1 --- /dev/null +++ b/man/man3/tomo-USE_COLOR.3 @@ -0,0 +1,18 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH USE_COLOR 3 2025-04-19T14:30:40.360080 "Tomo man-pages" +.SH NAME +USE_COLOR \- Whether or not the console prefers ANSI color escape sequences in the output. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI 'USE_COLOR : Bool' +.fi + +.SH DESCRIPTION +Whether or not the console prefers ANSI color escape sequences in the output. + diff --git a/man/man3/tomo-ask.3 b/man/man3/tomo-ask.3 new file mode 100644 index 00000000..f90d09ce --- /dev/null +++ b/man/man3/tomo-ask.3 @@ -0,0 +1,39 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH ask 3 2025-04-19T14:30:40.359728 "Tomo man-pages" +.SH NAME +ask \- Gets a line of user input text with a prompt. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "ask : func(prompt: Text, bold: Bool = yes, force_tty: Bool = yes -> Text?)" +.fi + +.SH DESCRIPTION +Gets a line of user input text with a prompt. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +prompt Text The text to print as a prompt before getting the input. - +bold Bool Whether or not to print make the prompt appear bold on a console. yes +force_tty Bool Whether or not to force the use of /dev/tty. yes +.TE +.SH RETURN +A line of user input text without a trailing newline, or empty text if something went wrong (e.g. the user hit `Ctrl-D`). + +.SH NOTES +When a program is receiving input from a pipe or writing its output to a pipe, this flag (which is enabled by default) forces the program to write the prompt to `/dev/tty` and read the input from `/dev/tty`, which circumvents the pipe. This means that `foo | ./tomo your-program | baz` will still show a visible prompt and read user input, despite the pipes. Setting this flag to `no` will mean that the prompt is written to `stdout` and input is read from `stdin`, even if those are pipes. + +.SH EXAMPLES +.EX +>> ask("What's your name? ") += "Arthur Dent" +.EE diff --git a/man/man3/tomo-exit.3 b/man/man3/tomo-exit.3 new file mode 100644 index 00000000..e285bd36 --- /dev/null +++ b/man/man3/tomo-exit.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH exit 3 2025-04-19T14:30:40.359796 "Tomo man-pages" +.SH NAME +exit \- Exits the program with a given status and optionally prints a message. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "exit : func(message: Text? = !Text, status: Int32 = Int32(1) -> Void)" +.fi + +.SH DESCRIPTION +Exits the program with a given status and optionally prints a message. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +message Text? If nonempty, this message will be printed (with a newline) before exiting. !Text +status Int32 The status code that the program with exit with. Int32(1) +.TE +.SH RETURN +This function never returns. + +.SH EXAMPLES +.EX +exit(status=1, "Goodbye forever!") +.EE diff --git a/man/man3/tomo-fail.3 b/man/man3/tomo-fail.3 new file mode 100644 index 00000000..a77ba9fa --- /dev/null +++ b/man/man3/tomo-fail.3 @@ -0,0 +1,33 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH fail 3 2025-04-19T14:30:40.360045 "Tomo man-pages" +.SH NAME +fail \- Prints a message to the console, aborts the program, and prints a stack trace. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "fail : func(message: Text -> Abort)" +.fi + +.SH DESCRIPTION +Prints a message to the console, aborts the program, and prints a stack trace. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +message Text The error message to print. - +.TE +.SH RETURN +Nothing, aborts the program. + +.SH EXAMPLES +.EX +fail("Oh no!") +.EE diff --git a/man/man3/tomo-getenv.3 b/man/man3/tomo-getenv.3 new file mode 100644 index 00000000..50bec810 --- /dev/null +++ b/man/man3/tomo-getenv.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH getenv 3 2025-04-19T14:30:40.359840 "Tomo man-pages" +.SH NAME +getenv \- Gets an environment variable. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "getenv : func(name: Text -> Text?)" +.fi + +.SH DESCRIPTION +Gets an environment variable. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +name Text The name of the environment variable to get. - +.TE +.SH RETURN +If set, the environment variable's value, otherwise, `none`. + +.SH EXAMPLES +.EX +>> getenv("TERM") += "xterm-256color"? +.EE diff --git a/man/man3/tomo-print.3 b/man/man3/tomo-print.3 new file mode 100644 index 00000000..52c55e91 --- /dev/null +++ b/man/man3/tomo-print.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH print 3 2025-04-19T14:30:40.359894 "Tomo man-pages" +.SH NAME +print \- Prints a message to the console (alias for [`say`](#say)). + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "print : func(text: Text, newline: Bool = yes -> Void)" +.fi + +.SH DESCRIPTION +Prints a message to the console (alias for [`say`](#say)). + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to print. - +newline Bool Whether or not to print a newline after the text. yes +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +print("Hello ", newline=no) +print("world!") +.EE diff --git a/man/man3/tomo-say.3 b/man/man3/tomo-say.3 new file mode 100644 index 00000000..f14db1f7 --- /dev/null +++ b/man/man3/tomo-say.3 @@ -0,0 +1,35 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH say 3 2025-04-19T14:30:40.359935 "Tomo man-pages" +.SH NAME +say \- Prints a message to the console. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "say : func(text: Text, newline: Bool = yes -> Void)" +.fi + +.SH DESCRIPTION +Prints a message to the console. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +text Text The text to print. - +newline Bool Whether or not to print a newline after the text. yes +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +say("Hello ", newline=no) +say("world!") +.EE diff --git a/man/man3/tomo-setenv.3 b/man/man3/tomo-setenv.3 new file mode 100644 index 00000000..0bd8baba --- /dev/null +++ b/man/man3/tomo-setenv.3 @@ -0,0 +1,34 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH setenv 3 2025-04-19T14:30:40.359972 "Tomo man-pages" +.SH NAME +setenv \- Sets an environment variable. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "setenv : func(name: Text, value: Text -> Void)" +.fi + +.SH DESCRIPTION +Sets an environment variable. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +name Text The name of the environment variable to set. - +value Text The new value of the environment variable. - +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +setenv("FOOBAR", "xyz") +.EE diff --git a/man/man3/tomo-sleep.3 b/man/man3/tomo-sleep.3 new file mode 100644 index 00000000..16d24e2d --- /dev/null +++ b/man/man3/tomo-sleep.3 @@ -0,0 +1,33 @@ +'\" t +.\" Copyright (c) 2025 Bruce Hill +.\" All rights reserved. +.\" +.TH sleep 3 2025-04-19T14:30:40.360009 "Tomo man-pages" +.SH NAME +sleep \- Pause execution for a given number of seconds. + +.SH LIBRARY +Tomo Standard Library +.SH SYNOPSIS +.nf +.BI "sleep : func(seconds: Num -> Void)" +.fi + +.SH DESCRIPTION +Pause execution for a given number of seconds. + + +.TS +allbox; +lb lb lbx lb +l l l l. +Name Type Description Default +seconds Num How many seconds to sleep for. - +.TE +.SH RETURN +Nothing. + +.SH EXAMPLES +.EX +sleep(1.5) +.EE |
