Skip to content

Instantly share code, notes, and snippets.

View petrounias's full-sized avatar
🐙
χταπόδι

Alexis Petrounias petrounias

🐙
χταπόδι
View GitHub Profile
@petrounias
petrounias / clojure-concat-performance-comparison.cljc
Last active August 26, 2021 17:04
Clojure concat performance comparison
; Comparing 'normal' versus lazy concat
(apply concat [[:a] [:b] [:c :d] [:e :f :g] [:h]])
; => (:a :b :c :d :e :f :g :h)
(take 3 (apply concat [[:a] [:b] [:c :d] [:e :f :g] [:h]]))
; => (:a :b :c)
; normal concat
@petrounias
petrounias / clojure-find-first-performance-comparison.cljc
Created August 26, 2021 08:26
Clojure find first performance comparison
; Comparing performance of 'normal' versus transducer 'find-first' in Clojure, where:
;
; (find-first (fn [thing] (number? thing)) [:foo 'bar 42 "zog" 67])
; => 42
; Normal version
(defn find-first
"Normal version."
@petrounias
petrounias / clojure-safe-merge-performance.cljc
Last active August 22, 2021 12:16
Clojure safe merge performance
(require '[criterium.core :as crit])
; figuring out the most performant way to merge two maps with only non-nil values in the right hand map,
; without failing for `false` values:
;
; (safe-merge {:foo true :bar 4} {:foo false :bar nil})
; => {:foo false, :bar 4}
;
; ordered by decreasing execution time mean
Verifying my Blockstack ID is secured with the address 1P1jxAMnfn9aRjWUjUGvbM1j9A8KyjWdhx https://explorer.blockstack.org/address/1P1jxAMnfn9aRjWUjUGvbM1j9A8KyjWdhx

Keybase proof

I hereby claim:

  • I am petrounias on github.
  • I am petrounias (https://keybase.io/petrounias) on keybase.
  • I have a public key whose fingerprint is C37C EEC3 77CB 6DED 0402 131F 5575 3CDF 8C85 6D85

To claim this, I am signing this object: