Niki Tonsky on Nostr: Useful Clojure functions that fit in toot (defn zip [& xs] (apply map vector xs)) ...
Useful Clojure functions that fit in toot
(defn zip [& xs]
(apply map vector xs))
(defn now []
(System/currentTimeMillis))
(defn between? [x from to]
(and
(<= from x)
(< x to)))
(defn index-of [x xs]
(loop [i 0 xs xs]
(cond
(nil? xs) nil
(= (first xs) x) i
:else (recur (inc i) (next xs)))))
(defn index-by [pred xs]
(loop [i 0 xs xs]
(cond
(nil? xs) nil
(pred (first xs)) i
:else (recur (inc i) (next xs)))))
(defn zip [& xs]
(apply map vector xs))
(defn now []
(System/currentTimeMillis))
(defn between? [x from to]
(and
(<= from x)
(< x to)))
(defn index-of [x xs]
(loop [i 0 xs xs]
(cond
(nil? xs) nil
(= (first xs) x) i
:else (recur (inc i) (next xs)))))
(defn index-by [pred xs]
(loop [i 0 xs xs]
(cond
(nil? xs) nil
(pred (first xs)) i
:else (recur (inc i) (next xs)))))