'boldital' => do { my $i = curry \&wrap_with_html => ( 'i' ); my $b = curry \&wrap_with_html => ( 'b' ); sub { $b->( $i->( @_ ) ) } },
Neat use of =>. As for composition, as an inveterate Haskell hacker (well, hacker-wannabe), I'd prefer to have that as a primitive, too:
The idea of functions that operate on functions and return other functions is much more useful than it first seemed to me. If you never think about functions as first-class objects, having a compose function seems incredibly redundant. Once you start building functions on-the-fly, composition becomes indispensible.sub compose { my ($f, $g) = @_; return sub { $f->($g->(@_)); } } # ... 'boldital' => &compose(&curry(\&wrap_with_html, 'i'), &curry(\&wrap_with_html, 'b')),
I guess I should write part 2 of my Perlesque Intro to Haskell, then.
--
F
o
x
t
r
o
t
U
n
i
f
o
r
m
Found a typo in this node? /msg me
% man 3 strfry
In reply to Re^3: Specializing Functions with Currying
by FoxtrotUniform
in thread Specializing Functions with Currying
by FoxtrotUniform
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |