aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-02-13 15:03:22 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-02-13 15:03:22 -0500
commit5be955904682300153af0abdfd6b711b9da2ac8f (patch)
treee616bc83904817fdefa43354fa815f13daf18739 /docs
parent8e0f1fa227be762cab19234abc106ba4c572077d (diff)
Deprecate Range datatype in favor of using iterator methods
Diffstat (limited to 'docs')
-rw-r--r--docs/README.md1
-rw-r--r--docs/integers.md23
-rw-r--r--docs/ranges.md65
3 files changed, 16 insertions, 73 deletions
diff --git a/docs/README.md b/docs/README.md
index e5253963..01e261f3 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -24,7 +24,6 @@ Information about Tomo's built-in types can be found here:
- [Moment](moments.md)
- [Enums](enums.md)
- [Floating point numbers](nums.md)
-- [Integer Ranges](ranges.md)
- [Integers](integers.md)
- [Languages](langs.md)
- [Mutexed Data](mutexed.md)
diff --git a/docs/integers.md b/docs/integers.md
index b69ed2b9..b6600314 100644
--- a/docs/integers.md
+++ b/docs/integers.md
@@ -297,25 +297,34 @@ of the representable range or if the entire text can't be parsed as an integer,
### `to`
**Description:**
-Creates an inclusive range of integers between the specified start and end values.
+Returns an iterator function that iterates over the range of numbers specified.
+Iteration is assumed to be nonempty and
**Signature:**
```tomo
-func to(from: Int, to: Int -> Range)
+func to(first: Int, last: Int, step : Int? = none:Int -> func(->Int?))
```
**Parameters:**
-- `from`: The starting value of the range.
-- `to`: The ending value of the range.
+- `first`: The starting value of the range.
+- `last`: The ending value of the range.
+- `step`: An optional step size to use. If unspecified or `none`, the step will be inferred to be `+1` if `last >= first`, otherwise `-1`.
**Returns:**
-A range object representing all integers from `from` to `to` (inclusive).
+An iterator function that returns each integer in the given range (inclusive).
**Example:**
```tomo
->> 1:to(5)
-= Range(first=1, last=5, step=1)
+>> 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]
```
---
diff --git a/docs/ranges.md b/docs/ranges.md
deleted file mode 100644
index 799b0eb3..00000000
--- a/docs/ranges.md
+++ /dev/null
@@ -1,65 +0,0 @@
-# Ranges
-
-Ranges are Tomo's way to do iteration over numeric ranges. Ranges are typically
-created using the `Int.to()` method like so: `5:to(10)`. Ranges are
-*inclusive*.
-
-```tomo
->> [i for i in 3:to(5)]
-= [3, 4, 5]
-```
-
----
-
-## Range Methods
-
-### `reversed`
-
-**Description:**
-Returns a reversed copy of the range.
-
-**Signature:**
-```tomo
-func reversed(range: Range -> Range)
-```
-
-**Parameters:**
-
-- `range`: The range to be reversed.
-
-**Returns:**
-A new `Range` with the order of elements reversed.
-
-**Example:**
-```tomo
->> 1:to(5):reversed()
-= Range(first=5, last=1, step=-1)
-```
-
----
-
-### `by`
-
-**Description:**
-Creates a new range with a specified step value.
-
-**Signature:**
-```tomo
-func by(range: Range, step: Int -> Range)
-```
-
-**Parameters:**
-
-- `range`: The original range.
-- `step`: The step value to be used in the new range.
-
-**Returns:**
-A new `Range` that increments by the specified step value.
-
-**Example:**
-```tomo
->> 1:to(5):by(2)
-= Range(first=1, last=5, step=2)
-```
-
----