sub sum { my ($term, $a, $next, $b) = @_; if ($a > $b) { return(0); } else { return( &$term($a) + &sum( &$term, (&$next($a)), (&$next($b)) ) ); } }