mirror of
https://github.com/janet-lang/janet
synced 2025-10-21 18:57:41 +00:00
Add eachk and eachp.
These should make iterating over datastructures easier without needing the loop macro.
This commit is contained in:
@@ -420,10 +420,20 @@
|
||||
[i start stop & body]
|
||||
(for-template i start stop 1 < + body))
|
||||
|
||||
(defmacro eachk
|
||||
"loop over each key in ds. returns nil."
|
||||
[x ds & body]
|
||||
(keys-template x ds false body))
|
||||
|
||||
(defmacro eachp
|
||||
"Loop over each (key, value) pair in ds. Returns nil."
|
||||
[x ds & body]
|
||||
(keys-template x ds true body))
|
||||
|
||||
(defmacro each
|
||||
"Loop over each value in ind. Returns nil."
|
||||
[x ind & body]
|
||||
(each-template x ind body))
|
||||
"Loop over each value in ds. Returns nil."
|
||||
[x ds & body]
|
||||
(each-template x ds body))
|
||||
|
||||
(defmacro loop
|
||||
"A general purpose loop macro. This macro is similar to the Common Lisp
|
||||
|
Reference in New Issue
Block a user