Jump to content

Sum and product of an array: Difference between revisions

Line 205:
set lstRange to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
{{sum:reduce(lstRange, summed, 0), product:reduce(lstRange)}, product, 1)}¬
{product:reduce(product, 1, lstRange)}}
end run
Line 227 ⟶ 228:
-- i: [ 1-based index in list ] optional
-- l: [ a reference to the list itself ] optional
on reduce(xsf, finitialValue, axs)
script mf
property lambda : f
end script
set v to ainitialValue
repeat with i from 1 to length of xs
set v to mf's lambda(v, item i of xs, i, xs)
Line 241 ⟶ 242:
{{Out}}
 
<prelang AppleScript>{{sum:55}, {product:3628800}}</prelang>
 
=={{header|AutoHotkey}}==
9,659

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.