code-reviews

jaihindhreddy 2021-05-24T14:43:21.006900Z

While the following is less efficient, it is more readable (to me), because it manipulates sequences in smaller steps, as opposed to merging those steps into one loop:

(defn minimum-absolute-difference [xs]
  (->> (sort xs)
       (partition 2 1)
       (map (fn [[x y]] (Math/abs (- x y))))
       (apply min)))
Also, all classes in java.lang are imported and referred by ns. So, you can use Math/abs in addition to the full name java.lang.Math/abs

2021-05-24T17:24:22.007300Z

it's not ns that does the scoping, but yes, most of java.lang is automatically in scope

1
jaihindhreddy 2021-05-24T17:50:56.007600Z

I always thought it was ns. Perhaps i'm confusing the import of java.lang with the requiring and referring of things in clojure.core Edit: sorry for the misleading statement earlier.