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


Spreadsheet-Engine documentation  | view source Contained in the Spreadsheet-Engine distribution.

Index


NAME

Top

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

SYNOPSIS

Top

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

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

DESCRIPTION

Top

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

Top

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

Top

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

Top

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

COPYRIGHT

Top

LICENCE

Top

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


Spreadsheet-Engine documentation  | view source Contained in the Spreadsheet-Engine distribution.