diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-05 00:21:30 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-05 00:21:30 -0500 |
| commit | 0a3ad8ba914ab42ebbb88a3d955f71d71d581fc1 (patch) | |
| tree | e984b58347627f0417a6961dbb8e83afe4739653 /docs/nums.md | |
| parent | 665050940f1562b045efe942686d04b3c3fac381 (diff) | |
Alphabetize and index functions
Diffstat (limited to 'docs/nums.md')
| -rw-r--r-- | docs/nums.md | 262 |
1 files changed, 156 insertions, 106 deletions
diff --git a/docs/nums.md b/docs/nums.md index aae6a48c..5589de57 100644 --- a/docs/nums.md +++ b/docs/nums.md @@ -119,6 +119,56 @@ called either on the type itself: `Num.sqrt(x)` or as a method call: --- +- [`func abs(n: Num -> Num)`](#`abs) +- [`func acos(x: Num -> Num)`](#`acos) +- [`func acosh(x: Num -> Num)`](#`acosh) +- [`func asin(x: Num -> Num)`](#`asin) +- [`func asinh(x: Num -> Num)`](#`asinh) +- [`func atan(x: Num -> Num)`](#`atan) +- [`func atan2(x: Num, y: Num -> Num)`](#`atan2) +- [`func atanh(x: Num -> Num)`](#`atanh) +- [`func cbrt(x: Num -> Num)`](#`cbrt) +- [`func ceil(x: Num -> Num)`](#`ceil) +- [`clamped(x, low, high: Num -> Num)`](#`clamped) +- [`func copysign(x: Num, y: Num -> Num)`](#`copysign) +- [`func cos(x: Num -> Num)`](#`cos) +- [`func cosh(x: Num -> Num)`](#`cosh) +- [`func erf(x: Num -> Num)`](#`erf) +- [`func erfc(x: Num -> Num)`](#`erfc) +- [`func exp(x: Num -> Num)`](#`exp) +- [`func exp2(x: Num -> Num)`](#`exp2) +- [`func expm1(x: Num -> Num)`](#`expm1) +- [`func fdim(x: Num, y: Num -> Num)`](#`fdim) +- [`func floor(x: Num -> Num)`](#`floor) +- [`func format(n: Num, precision: Int = 0 -> Text)`](#`format) +- [`func hypot(x: Num, y: Num -> Num)`](#`hypot) +- [`func isfinite(n: Num -> Bool)`](#`isfinite) +- [`func isinf(n: Num -> Bool)`](#`isinf) +- [`func j0(x: Num -> Num)`](#`j0) +- [`func j1(x: Num -> Num)`](#`j1) +- [`func log(x: Num -> Num)`](#`log) +- [`func log10(x: Num -> Num)`](#`log10) +- [`func log1p(x: Num -> Num)`](#`log1p) +- [`func log2(x: Num -> Num)`](#`log2) +- [`func logb(x: Num -> Num)`](#`logb) +- [`func mix(amount: Num, x: Num, y: Num -> Num)`](#`mix) +- [`func near(x: Num, y: Num, ratio: Num = 1e-9, min_epsilon: Num = 1e-9 -> Bool)`](#`near) +- [`func nextafter(x: Num, y: Num -> Num)`](#`nextafter) +- [`func parse(text: Text -> Num?)`](#`parse) +- [`func rint(x: Num -> Num)`](#`rint) +- [`func round(x: Num -> Num)`](#`round) +- [`func scientific(n: Num, precision: Int = 0 -> Text)`](#`scientific) +- [`func significand(x: Num -> Num)`](#`significand) +- [`func sin(x: Num -> Num)`](#`sin) +- [`func sinh(x: Num -> Num)`](#`sinh) +- [`func sqrt(x: Num -> Num)`](#`sqrt) +- [`func tan(x: Num -> Num)`](#`tan) +- [`func tanh(x: Num -> Num)`](#`tanh) +- [`func tgamma(x: Num -> Num)`](#`tgamma) +- [`func trunc(x: Num -> Num)`](#`trunc) +- [`func y0(x: Num -> Num)`](#`y0) +- [`func y1(x: Num -> Num)`](#`y1) + ### `abs` **Description:** @@ -244,52 +294,52 @@ The inverse hyperbolic sine of `x`. --- -### `atan2` +### `atan` **Description:** -Computes the arc tangent of the quotient of two numbers. +Computes the arc tangent of a number. **Signature:** ```tomo -func atan2(x: Num, y: Num -> Num) +func atan(x: Num -> Num) ``` **Parameters:** -- `x`: The numerator. -- `y`: The denominator. +- `x`: The number for which the arc tangent is to be calculated. **Returns:** -The arc tangent of `x/y` in radians. +The arc tangent of `x` in radians. **Example:** ```tomo ->> Num.atan2(1, 1) // -> (π/4) +>> 1.0:atan() // -> (π/4) = 0.7854 ``` --- -### `atan` +### `atan2` **Description:** -Computes the arc tangent of a number. +Computes the arc tangent of the quotient of two numbers. **Signature:** ```tomo -func atan(x: Num -> Num) +func atan2(x: Num, y: Num -> Num) ``` **Parameters:** -- `x`: The number for which the arc tangent is to be calculated. +- `x`: The numerator. +- `y`: The denominator. **Returns:** -The arc tangent of `x` in radians. +The arc tangent of `x/y` in radians. **Example:** ```tomo ->> 1.0:atan() // -> (π/4) +>> Num.atan2(1, 1) // -> (π/4) = 0.7854 ``` @@ -370,6 +420,34 @@ The smallest integer greater than or equal to `x`. --- +### `clamped` + +**Description:** +Returns the given number clamped between two values so that it is within +that range. + +**Signature:** +```tomo +clamped(x, low, high: Num -> Num) +``` + +**Parameters:** + +- `x`: The number to clamp. +- `low`: The lowest value the result can take. +- `high`: The highest value the result can take. + +**Returns:** +The first argument clamped between the other two arguments. + +**Example:** +```tomo +>> 2.5:clamped(5.5, 10.5) += 5.5 +``` + +--- + ### `copysign` **Description:** @@ -496,14 +574,14 @@ The complementary error function of `x`. --- -### `exp2` +### `exp` **Description:** -Computes \( 2^x \) for a number. +Computes the exponential function \( e^x \) for a number. **Signature:** ```tomo -func exp2(x: Num -> Num) +func exp(x: Num -> Num) ``` **Parameters:** @@ -511,24 +589,24 @@ func exp2(x: Num -> Num) - `x`: The exponent. **Returns:** -The value of \( 2^x \). +The value of \( e^x \). **Example:** ```tomo ->> 3.0:exp2() -= 8 +>> 1.0:exp() += 2.7183 ``` --- -### `exp` +### `exp2` **Description:** -Computes the exponential function \( e^x \) for a number. +Computes \( 2^x \) for a number. **Signature:** ```tomo -func exp(x: Num -> Num) +func exp2(x: Num -> Num) ``` **Parameters:** @@ -536,12 +614,12 @@ func exp(x: Num -> Num) - `x`: The exponent. **Returns:** -The value of \( e^x \). +The value of \( 2^x \). **Example:** ```tomo ->> 1.0:exp() -= 2.7183 +>> 3.0:exp2() += 8 ``` --- @@ -650,34 +728,6 @@ A text representation of the number with the specified precision. --- -### `parse` - -**Description:** -Converts a text representation of a number into a floating-point number. - -**Signature:** -```tomo -func parse(text: Text -> Num?) -``` - -**Parameters:** - -- `text`: The text containing the number. - -**Returns:** -The number represented by the text or `none` if the entire text can't be parsed -as a number. - -**Example:** -```tomo ->> Num.parse("3.14") -= 3.14 ->> Num.parse("1e3") -= 1000 -``` - ---- - ### `hypot` **Description:** @@ -808,6 +858,31 @@ The Bessel function of the first kind of order 1 of `x`. --- +### `log` + +**Description:** +Computes the natural logarithm (base \( e \)) of a number. + +**Signature:** +```tomo +func log(x: Num -> Num) +``` + +**Parameters:** + +- `x`: The number for which the natural logarithm is to be calculated. + +**Returns:** +The natural logarithm of `x`. + +**Example:** +```tomo +>> Num.E:log() += 1 +``` + +--- + ### `log10` **Description:** @@ -883,31 +958,6 @@ The base-2 logarithm of `x`. --- -### `log` - -**Description:** -Computes the natural logarithm (base \( e \)) of a number. - -**Signature:** -```tomo -func log(x: Num -> Num) -``` - -**Parameters:** - -- `x`: The number for which the natural logarithm is to be calculated. - -**Returns:** -The natural logarithm of `x`. - -**Example:** -```tomo ->> Num.E:log() -= 1 -``` - ---- - ### `logb` **Description:** @@ -1024,6 +1074,34 @@ The next representable value after `x` in the direction of `y`. --- +### `parse` + +**Description:** +Converts a text representation of a number into a floating-point number. + +**Signature:** +```tomo +func parse(text: Text -> Num?) +``` + +**Parameters:** + +- `text`: The text containing the number. + +**Returns:** +The number represented by the text or `none` if the entire text can't be parsed +as a number. + +**Example:** +```tomo +>> Num.parse("3.14") += 3.14 +>> Num.parse("1e3") += 1000 +``` + +--- + ### `rint` **Description:** @@ -1353,31 +1431,3 @@ The Bessel function of the second kind of order 1 of `x`. >> 1.0:y1() = 0.4401 ``` - ---- - -### `clamped` - -**Description:** -Returns the given number clamped between two values so that it is within -that range. - -**Signature:** -```tomo -clamped(x, low, high: Num -> Num) -``` - -**Parameters:** - -- `x`: The number to clamp. -- `low`: The lowest value the result can take. -- `high`: The highest value the result can take. - -**Returns:** -The first argument clamped between the other two arguments. - -**Example:** -```tomo ->> 2.5:clamped(5.5, 10.5) -= 5.5 -``` |
