From f857f38f718fff586e373815a1bcad2701b4d983 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 7 Apr 2025 01:17:02 -0400 Subject: Add `is_between()` for various types --- docs/nums.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'docs/nums.md') diff --git a/docs/nums.md b/docs/nums.md index 1cc3782a..62cf3564 100644 --- a/docs/nums.md +++ b/docs/nums.md @@ -143,6 +143,7 @@ called either on the type itself: `Num.sqrt(x)` or as a method call: - [`func format(n: Num, precision: Int = 0 -> Text)`](#format) - [`func hypot(x: Num, y: Num -> Num)`](#hypot) - [`func isfinite(n: Num -> Bool)`](#isfinite) +- [`func is_between(n: Num, low: Num, high: Num -> Bool)`](#is_between) - [`func isinf(n: Num -> Bool)`](#isinf) - [`func j0(x: Num -> Num)`](#j0) - [`func j1(x: Num -> Num)`](#j1) @@ -662,6 +663,32 @@ func isfinite(n: Num -> Bool) --- +### `is_between` +Determines if a number is between two numbers (inclusive). + +```tomo +func is_between(x: Num, low: Num, high: Num -> Bool) +``` + +- `x`: The integer to be checked. +- `low`: The lower bound to check (inclusive). +- `high`: The upper bound to check (inclusive). + +**Returns:** +`yes` if `low <= x and x <= high`, otherwise `no` + +**Example:** +```tomo +>> (7.5).is_between(1, 10) += yes +>> (7.5).is_between(100, 200) += no +>> (7.5).is_between(1, 7.5) += yes +``` + +--- + ### `isinf` Checks if a number is infinite. -- cgit v1.2.3