aboutsummaryrefslogtreecommitdiff
path: root/docs/integers.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/integers.md
parentfb4e4cef1382a5e37d99ccb8e97fe1d2a8cd7e93 (diff)
Add `is_between()` for various types
Diffstat (limited to 'docs/integers.md')
-rw-r--r--docs/integers.md27
1 files changed, 27 insertions, 0 deletions
diff --git a/docs/integers.md b/docs/integers.md
index 84a2d1a2..1ee47cbd 100644
--- a/docs/integers.md
+++ b/docs/integers.md
@@ -128,6 +128,7 @@ can be called either on the type itself: `Int.sqrt(x)` or as a method call:
- [`func factorial(n: Int -> Text)`](#factorial)
- [`func format(i: Int, digits: Int = 0 -> Text)`](#format)
- [`func hex(i: Int, digits: Int = 0, uppercase: Bool = yes, prefix: Bool = yes -> Text)`](#hex)
+- [`func is_between(x: Int, low: Int, high: Int -> Bool)`](#is_between)
- [`func is_prime(x: Int, reps: Int = 50 -> Bool)`](#is_prime)
- [`func next_prime(x: Int -> Int)`](#next_prime)
- [`func octal(i: Int, digits: Int = 0, prefix: Bool = yes -> Text)`](#octal)
@@ -268,6 +269,32 @@ The hexadecimal string representation of the integer.
---
+### `is_between`
+Determines if an integer is between two numbers (inclusive).
+
+```tomo
+func is_between(x: Int, low: Int, high: Int -> 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).is_between(1, 10)
+= yes
+>> (7).is_between(100, 200)
+= no
+>> (7).is_between(1, 7)
+= yes
+```
+
+---
+
### `is_prime`
Determines if an integer is a prime number.