1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-28 19:19:53 +00:00

Make zipcoll more generic.

Work with any iterable (next) type.
This commit is contained in:
Calvin Rose 2020-06-24 16:10:57 -05:00
parent ac5de1f96e
commit 6a187a384b

View File

@ -1236,11 +1236,14 @@
Returns a new table."
[ks vs]
(def res @{})
(def lk (length ks))
(def lv (length vs))
(def len (if (< lk lv) lk lv))
(for i 0 len
(put res (in ks i) (in vs i)))
(var kk nil)
(var vk nil)
(while true
(set kk (next ks kk))
(if (= nil kk) (break))
(set vk (next vs vk))
(if (= nil vk) (break))
(put res (in ks kk) (in vs vk)))
res)
(defn get-in