Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SWIFT

sum in array swift

extension Sequence  {
    func sum<T: AdditiveArithmetic>(_ predicate: (Element) -> T) -> T { reduce(.zero) { $0 + predicate($1) } }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sum #array #swift
ADD COMMENT
Topic
Name
3+3 =