aboutsummaryrefslogtreecommitdiff
path: root/docs/nums.md
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-07 01:17:02 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-07 01:17:02 -0400
commitf857f38f718fff586e373815a1bcad2701b4d983 (patch)
tree29b3e367437099f39f6fc9a4e7d1dd2f177afb59 /docs/nums.md
parentfb4e4cef1382a5e37d99ccb8e97fe1d2a8cd7e93 (diff)
Add `is_between()` for various types
Diffstat (limited to 'docs/nums.md')
-rw-r--r--docs/nums.md27
1 files changed, 27 insertions, 0 deletions
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.