- or download this
sub printN($) { my $format = shift; sub { sprintf $format, @_ } }
...
-f5 => printN "%.5f",
);
- or download this
my @func_pipeline = grep {$_} map {$functions{"$_"}} @ARGV;
@ARGV = grep {!$functions{"$_"}} @ARGV;
- or download this
sub compose($$) { my ($f, $g) = @_; sub { $f->( $g->(@_) ) } }
sub id { @_ }; # identity function
my $composite_fn = reduce {compose($a,$b)} @func_pipeline, \&id;
- or download this
print join ' ', map $composite_fn->($_), split while <>;
- or download this
#!/usr/bin/perl -l
...
my $composite_fn = reduce {compose($a,$b)} @func_pipeline, \&id;
print join ' ', map $composite_fn->($_), split while <>;
- or download this
$ echo 1 2 3 | ./calc-pipeline -f4 -power
2.7183 7.3891 20.0855