1 clojure comment ;;; Copyright (C) 2009 Brendan Ribera. All rights reserved.
2 clojure comment ;;; Distributed under the MIT License; see the file LICENSE
3 clojure comment ;;; at the root of this distribution.
4 clojure code (ns kdtree)
6 clojure code (defn dist-squared [a b]
7 clojure code "Compute the K-dimensional distance between two points"
8 clojure code (reduce + (for [i (range (count a))]
9 clojure code (let [v (- (nth a i)
10 clojure code (nth b i))]
11 clojure code (* v v)))))
13 clojure comment ;;; Simple accessors
14 clojure code (defn- node-value [n] (first n))
15 clojure code (defn- node-left [n] (first (rest n)))
16 clojure code (defn- node-right [n] (first (rest (rest n))))