Skip to content

Commit 2950bc6

Browse files
committed
Add each-in-closed-interval-descending
1 parent 1f97d4b commit 2950bc6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

runtime/CHelpers.cake

+11
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,17 @@
255255
(token-splice-rest body tokens)))
256256
(return true))
257257

258+
;; [start, end] where start >= end
259+
(defmacro each-in-closed-interval-descending (start-max any end-min any
260+
iterator-name symbol
261+
&rest body any)
262+
(tokenize-push output
263+
(c-for (var (token-splice iterator-name) int (token-splice start-max))
264+
(>= (token-splice iterator-name) (token-splice end-min))
265+
(decr (token-splice iterator-name))
266+
(token-splice-rest body tokens)))
267+
(return true))
268+
258269
(defmacro each-char-in-string (start-char any iterator-name symbol &rest body any)
259270
(tokenize-push output
260271
(c-for (var (token-splice iterator-name) (* char) (token-splice start-char))

tools/cakelisp.el

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
;; Macros
2626
(put 'each-in-range 'lisp-indent-function 2)
2727
(put 'each-in-interval 'lisp-indent-function 3)
28+
(put 'each-in-closed-interval-descending 'lisp-indent-function 3)
2829
(put 'each-in-array 'lisp-indent-function 2)
2930
(put 'each-char-in-string 'lisp-indent-function 2)
3031
(put 'each-char-in-string-const 'lisp-indent-function 2)

0 commit comments

Comments
 (0)