Why Nostr? What is Njump?
2024-05-31 17:44:01

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)))))
Author Public Key
npub1tlmx3jvm6jrzaq98cef5pljjscaa520uzgtm7d0cmfyckekzn89sksd72v