=item calculate_area The calculate_area function calculates the area of the points passed in. You can pass the points in a number of different ways, but, regardless, you'll get the area back. =over 4 =item * You can pass in a series of points. The function will assume that the shape described is a closed-shape, that is, the first point is automatically repeated as the end point. You can pass in the points as perl6 pairs, e.g.: $area = calculate_area( $x0 => $y0, $x1 => $y1 ); or as two lists of x's and y's: $area = calculate_area( @x, @y ); or as a list of Point objects $area = calculate_area( @points ); =item * You can pass in a Shape object. $area = calculate_area( $shape ); =item * You can pass in an equation, and a beginning x-value and an ending x-value, and the area will be that under the curve. The area may be negative in this case. $area = calculate_area( $equation, $x0, $x1 ); =back Returns: the area of the shape, in square units. =cut #### sub calculate_area { unless ( grep { ref $_ ne 'Pair' } @_ ) { goto \&_calculate_area_pairs; } if (@_ % 2 == 0 and not ref $_[0]) { goto \&_calculate_area_x_list_y_list; } unless ( grep { ref $_ ne 'Point' } @_ ) { goto \&_calculate_area_list_of_points; } unless ( grep { ref $_ ne 'ARRAY' } @_ ) { goto \&_calculate_area_list_of_arrays; } if (UNIVERSAL::isa($_[0], 'Shape')) { goto \&_calculate_area_share; } if (UNIVERSAL::isa($_[0], 'Equation') and @_ == 3) { goto \&_calculate_area_equation; } die "Didn't recognise how you called calculate_area"; }