Logo

Programming-Idioms

History of Idiom 54 > diff from v40 to v41

Edit summary for version 41 by OC:
New Obj-C implementation by user [OC]

Version 40

2020-05-10, 21:43:48

Version 41

2020-10-10, 20:55:13

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
Imports
@import Foundation;
Code
id s=[x valueForKeyPath:@"@sum.self"];
Comments bubble
Plain-C like solutions also possible; showing here a more generic approach based on the key-value coding
Doc URL
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/KeyValueCoding/CollectionOperators.html#//apple_ref/doc/uid/20002176-BAJEAIEE