aboutsummaryrefslogtreecommitdiff
path: root/builtins/integers.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-05 14:40:28 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-05 14:40:28 -0400
commitc045c54309dfaa7bb11f97dc3f36c595736eca3b (patch)
tree52c6b1602adf5d334be6e913273b609d1e88eaa4 /builtins/integers.c
parent8e2156ac483e7fa0f2007188b670eb11f2a44720 (diff)
Add a Range datatype with creation methods like `5:to(10)` and
modification methods like `range:by(2)` or `range:reversed()`
Diffstat (limited to 'builtins/integers.c')
-rw-r--r--builtins/integers.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/builtins/integers.c b/builtins/integers.c
index d50c6573..db1a73e2 100644
--- a/builtins/integers.c
+++ b/builtins/integers.c
@@ -68,6 +68,9 @@
} \
return (c_type)((uint64_t)min + (r % range)); \
} \
+ public Range_t KindOfInt ## $to(c_type from, c_type to) { \
+ return (Range_t){from, to, to >= from ? 1 : -1}; \
+ } \
public c_type KindOfInt ## $from_text(CORD text, CORD *the_rest) { \
const char *str = CORD_to_const_char_star(text); \
long i; \