Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Dart

Idiom #202 Sum of squares

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

var s = data.map((v) => v * v).reduce((sum, v) => sum + v);
(defn square [x] (* x x))

(def s (->> data (map square) (reduce +)))

New implementation...
< >
Bart