This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-25
Channels
- # announcements (1)
- # beginners (131)
- # cljs-dev (1)
- # clojure (178)
- # clojure-argentina (1)
- # clojure-dev (3)
- # clojure-uk (2)
- # clojuredesign-podcast (1)
- # clojurescript (16)
- # code-reviews (2)
- # core-async (2)
- # emacs (28)
- # figwheel-main (19)
- # fulcro (11)
- # kaocha (1)
- # leiningen (4)
- # music (6)
- # off-topic (2)
- # re-frame (2)
- # reitit (6)
- # rewrite-clj (9)
- # shadow-cljs (78)
- # slack-help (6)
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))