hi guys, I'm converting a function that uses a ref to a loop/recur, but this function isn't amenable to tail recursion because it has multiple if's that may change the result... any quick shots?
(defn point-query
([tree point]
(let [results (ref [])
(point-query tree (get-root tree) point results)]
@results))
([tree node point results]
(if (not= node (get-sentinel tree))
(let [interval (get-interval node)]
(if (<= point (get-max node))
(point-query tree (get-left node) point results))
(if (interval-tree.interval/contains interval point)
(alter results conj (get-interval node) (get-value node)))
(if (>= point (low interval))
(point-query tree (get-right node) point results))))
results))
those 3 if
s can happen in the same fn call