sub foldf
{
   my ($f,$id,@L) = @_; # the list is the last arg to avoid using pointers
   if (!@L) { return $id } # if L is null, return id
   my ($car,@cdr) = @L; # break list into car and cdr
   $f->($car,foldf($f,$id,@cdr))
}

@l = (1,2,3,4);
print "hello\n";
#print foldf(sub{$_[0]*$_[1]},1,());
print foldf(sub{$_[0]*$_[1]},1,@l);
print "\n";
