Logo

Programming-Idioms

History of Idiom 54 > diff from v50 to v51

Edit summary for version 51 by programming-idioms.org:
[Clojure] Variable name x

Version 50

2021-06-06, 08:51:39

Version 51

2021-06-06, 20:15:23

Idiom #54 Compute sum of integers

Calculate the sum s of integer list x.

Idiom #54 Compute sum of integers

Calculate the sum s of integer list x.

Variables
s,x
Variables
s,x
Code
(defn sum [xs] (reduce + xs))

(sum [1 20 300])
;;=> 321
Code
(defn sum [x] (reduce + x))

(sum [1 20 300])
;;=> 321
Comments bubble
xs is a collection of integers.
Comments bubble
x is a collection of integers.