aboutsummaryrefslogtreecommitdiff
path: root/challenge-171/polettix/perl/ch-2.pl
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-171/polettix/perl/ch-2.pl')
-rw-r--r--challenge-171/polettix/perl/ch-2.pl13
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-171/polettix/perl/ch-2.pl b/challenge-171/polettix/perl/ch-2.pl
new file mode 100644
index 0000000000..ffb302d27f
--- /dev/null
+++ b/challenge-171/polettix/perl/ch-2.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/env perl
+use v5.24;
+use warnings;
+use experimental 'signatures';
+no warnings 'experimental::signatures';
+
+my $h1 = compose(sub { $_[0] + 1 }, sub { $_[0] * 2 });
+say $h1->(1);
+
+my $h2 = compose(sub { $_[0] * 2 }, sub { $_[0] + 1 });
+say $h2->(1);
+
+sub compose ($f, $g) { sub { $f->($g->(@_)) } }