# Method Concurrent.fold()

Method fold

  ``Future` fold(`array`(`Future`) `futures`, `mixed` `initial`, `function`(`mixed`, `mixed`, `mixed` ... :`mixed`) `fun`, `mixed` ... `extra`)`

Description

  Return a Future that represents the accumulated results of applying `fun` to the results of the `futures` in turn.

Parameter `initial`

  Initial value of the accumulator.

Parameter `fun`

  Function to apply. The first argument is the result of one of the `futures`, the second the current accumulated value, and any further from `extra`.

Note

  If `fun` throws an error it will fail the Future.

Note

  `fun` may be called in any order, and will be called once for every Future in `futures`, unless one of calls fails in which case no further calls will be performed.

Note

  The returned Future does NOT have any state (eg backend) propagated from the `futures`. This must be done by hand.