Skip to content

Instantly share code, notes, and snippets.

View looselytyped's full-sized avatar

Raju Gandhi looselytyped

View GitHub Profile
(defn xconj [t v]
(cond (nil? t) {:val v, :l nil, :r nil}
(< v (:val t)) (cond
(nil? (:l t)) {:val (:val t), :l (xconj nil v), :r (:r t)}
:else {:val (:val t), :l (xconj (:l t) v), :r (:r t)})
:else (cond (nil? (:r t)) {:val (:val t), :l (:l t), :r (xconj nil v)}
:else {:val (:val t), :l (:l t), :r (xconj (:r t) v)})))
(defn xseq [t]