Last active
August 22, 2023 17:28
-
-
Save igrishaev/9662099637ba2ba390dc173aaa722ca0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(letfn [(->iter [coll] | |
(clojure.lang.RT/iter coll)) | |
(has-next? [iter] | |
(.hasNext ^java.util.Iterator iter)) | |
(next! [iter] | |
(.next ^java.util.Iterator iter))] | |
(defn map! | |
([f coll] | |
(mapv f coll)) | |
([f coll & colls] | |
(let [iters (map ->iter (cons coll colls))] | |
(loop [acc! (transient [])] | |
(if (every? has-next? iters) | |
(let [item (apply f (map next! iters))] | |
(recur (conj! acc! item))) | |
(persistent! acc!))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment