first commit

This commit is contained in:
douboer
2026-09-30 15:05:17 +08:00
commit 34cf39dfe3
1288 changed files with 118174 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
###
### reduce
###
## Chapter 7 section 3
sub reduce (&;$@) {
my $code = shift;
my $f = sub {
my $base_val = shift;
my $g = sub {
my $val = $base_val;
for (@_) {
local ($a, $b) = ($val, $_);
$val = $code->($val, $_);
}
return $val;
};
@_ ? $g->(@_) : $g;
};
@_ ? $f->(@_) : $f;
}