Logo

Programming-Idioms

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

Idiom #202 Sum of squares

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

uses math;
var
  data: array of double;
...
  s := SumOfSquares(data);
...
(defn square [x] (* x x))

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

New implementation...
< >
Bart