Sum and product of an array: Difference between revisions

m
Line 1,576:
 
=={{header|FutureBasic}}==
Traditional
<syntaxhighlight lang="futurebasic">
local fn Sum( mutArr as CFMutableArrayRef ) as float
Line 1,602 ⟶ 1,603:
end fn = prod
</syntaxhighlight>
Sum of array elements with key-value coding
<syntaxhighlight lang="futurebasic">
local fn NumericalArraySum( array as CFArrayRef ) as CFNumberRef
end fn = fn ObjectValueForKeyPath( array, @"@sum.self" )
 
printf @"%@", fn NumericalArraySum( @[@0.0454, @-1.3534, @0.345, @65, @-0.345, @1.35] )
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
65.042
</pre>
 
=={{header|Fōrmulæ}}==
717

edits