Name

list::reduce — Reduces a list to a single value.

Synopsis

flex1 list::reduce ( flex1 x ,
  flex1 y ,
  list<flex1> list ,
  block<flex1> expression );
 

Parameters

flex1 x

flex1 y

list<flex1> list

block<flex1> expression

Return

flex1

Description

Apply expression cumulatively to the values of the list, from left to right, to reduce the list to a single value. See http://en.wikipedia.org/wiki/Reduce_(higher-order_function) for a detailed explanation.

In this version the initial value is the first value of the list. Thus the list must not be empty.

Usage

  list::reduce (integer x, integer y, [2, 4, 6], { return x < y ? x : y; }) -> 2
 

  list::reduce (integer x, integer y, [2, 4, 6], { return x > y ? x : y; }) -> 6