package Experimental::Composition; use base 'Exporter'; our @EXPORT = qw(composition); sub composition{ my @funcs = @_; my $apply; $apply = sub{ my $funcs = shift; my $f = shift @{$funcs}; return (scalar @{$funcs} > 0) ? $apply->($funcs, $f->(@_)): $f->(@_); }; return sub{ return $apply->(\@funcs, @_); }; } 1;