Sequence
extension Sequence
extension Sequence where Element: Additive
extension Sequence where Element: Multiplicative
extension Sequence where Element: Monoid
extension Sequence where Element: MonoidView
-
let numbers = [1,2,3] let accumulatedAdditionFrom10 = numbers.accumulating(10,+) // => [10,11,13]Declaration
Swift
public func accumulating( _ initial: Element, _ op: (Element,Element) -> Element ) -> [Element]Return Value
An array of values starting with the given
initial, followed by each element combined with the accumulation with the givenop.
-
let numbers = [2,1,2] let accumulated = numbers.accumulatingSum // => [0,2,3]Declaration
Swift
public var accumulatingSum: [Element] { get }Return Value
An array of values from
.zero, applying+to each element contained herein and the accumulative value.
-
let numbers = [2,1,2] let accumulated = numbers.accumulatingProduct // => [1,2,2]Declaration
Swift
public var accumulatingProduct: [Element] { get }Return Value
An array of values from
.one, applying*to each element contained herein and the accumulative value.
-
Declaration
Swift
public var product: Element { get }Return Value
Product of all values contained herein.
View on GitHub
Install in Dash
Sequence Extension Reference