Jump to content

Sum and product of an array: Difference between revisions

(→‎{{header|Perl}}: Dropped third example. 'foreach' is definitely to be preferred over 'map' in void context.)
Line 206:
Sum = sum [x \\ x <-: array]
Prod = foldl (*) 1 [x \\ x <-: array]</lang>
=={{header|Clojure}}==
 
<lang lisp>
(defn sum [vals] (reduce + vals))
 
(defn product [vals] (reduce * vals))
</lang>
 
=={{header|ColdFusion}}==
Sum of an Array,
Line 218 ⟶ 226:
</cfloop>
<cfoutput>#Variables.Product#</cfoutput></lang>
 
=={{header|Common Lisp}}==
<lang lisp>(let ((data #(1 2 3 4 5))) ; the array
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.