Help for this page

Select Code to Download


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