Help for this page

Select Code to Download


  1. or download this
    #! perl -l
    
    ...
    # f(x)
    print $g->("x");
    # g(x)
    
  2. or download this
    sub compose2 {
        my ($f, $g) = @_;
        sub { $f->( $g->(@_) ) }
    }
    
  3. or download this
    my $h = compose2( $f, $g );
    print $h->("x");
    # f(g(x))
    
  4. or download this
    sub foldl {
        my $f = shift;
    ...
    sub compose {
        foldl( \&compose2, @_ )
    }
    
  5. or download this
    print compose( $f,$f,$f,$f,$f,$f,$g )->("x");
    # f(f(f(f(f(f(g(x)))))))
    ...
    
    print compose( ($add1) x 4 )->(0);
    # 4