NAME

Spreadsheet::Engine::Function::series - base class for series functions

SYNOPSIS

use base 'Spreadsheet::Engine::Function::series';

sub calculate { 
  return sub { 
    my ($value, $accumulator) = @_;
    # ... do stuff
    return $accumulator;
  };
}

DESCRIPTION

This provides a base class for spreadsheet functions that reduce a list of values to a single number, such as SUM(), MIN(), MAX() etc.

METHODS

argument_count

By default all such functions take one or more argument.

result_type

This usualy depends on the types of the arguments passed. See the typelookup table in Spreadsheet::Engine::Sheet for more details.

TO SUBCLASS

calculate

Returns a subref that is given each value in turn along with the accumulator, and returns the new value for the accumulator.

accumulator

This should provide the initial accumulator value. The default is to set it to undef.

result_from($accumulator)

Calculate the result based on the accumulator. The default is that the result is whatever value is in the accumulator. Functions such as AVERAGE() that need to perform extra calculations at the end can override this.

HISTORY

This is a Modified Version of code extracted from SocialCalc::Functions in SocialCalc 1.1.0

COPYRIGHT

Portions (c) Copyright 2005, 2006, 2007 Software Garden, Inc. All Rights Reserved.

Portions (c) Copyright 2007 Socialtext, Inc. All Rights Reserved.

Portions (c) Copyright 2007, 2008 Tony Bowden

LICENCE

The contents of this file are subject to the Artistic License 2.0; you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.perlfoundation.org/artistic_license_2_0