use Inline C;

@array = (1 .. 20);
# use pointer access with \
$s = sum(\@array);    
print "sum = $s\n"

__END__
__C__
double sum(AV* array) {
	int i;
	double s = 0.0;
  
	// here av_len(array) = #elements-1
	for (i=0; i<=av_len(array); i++) {
		SV** elem = av_fetch(array, i, 0);
		if (elem != NULL) {
			s += SvNV(*elem);
		}
	}
  
	return s;
}
