Skip to content

Instantly share code, notes, and snippets.

@Sophia-Gold
Created August 18, 2017 03:52
Show Gist options
  • Select an option

  • Save Sophia-Gold/aa2d2782e92f9e2c29d12976d3b731d9 to your computer and use it in GitHub Desktop.

Select an option

Save Sophia-Gold/aa2d2782e92f9e2c29d12976d3b731d9 to your computer and use it in GitHub Desktop.
(defn halve [i]
(bit-shift-right i 1))
(defn double [i]
(bit-shift-left i 1))
(defn mul [x y]
(let [x (take-while #(not= % 0) (iterate halve x))]
(->> y
(iterate double)
(take (count x))
(map #(if (odd? %1) %2 0) x)
(reduce + 0))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment