Logo

Programming-Idioms

History of Idiom 202 > diff from v13 to v14

Edit summary for version 14 by programming-idioms.org:
New Clojure implementation by user [programming-idioms.org]

Version 13

2020-04-29, 12:10:45

Version 14

2020-05-03, 21:11:02

Idiom #202 Sum of squares

Calculate the sum of squares s of data, an array of floating point values.

Idiom #202 Sum of squares

Calculate the sum of squares s of data, an array of floating point values.

Variables
s,data
Code
(defn square [x] (* x x))

(def s (->> data (map square) (reduce +)))
Doc URL
https://clojuredocs.org/clojure.core/-%3E%3E