in reply to Re^2: Specializing Functions with Currying
in thread Specializing Functions with Currying
'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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Specializing Functions with Currying
by stvn (Monsignor) on Aug 06, 2004 at 13:46 UTC | |
by Aristotle (Chancellor) on Aug 06, 2004 at 22:55 UTC | |
by jryan (Vicar) on Aug 06, 2004 at 21:03 UTC | |
by stvn (Monsignor) on Aug 06, 2004 at 21:56 UTC | |
by jryan (Vicar) on Aug 06, 2004 at 22:21 UTC | |
by tilly (Archbishop) on Aug 06, 2004 at 22:29 UTC | |
| |
by stvn (Monsignor) on Aug 06, 2004 at 23:04 UTC | |
| |
by ihb (Deacon) on Aug 08, 2004 at 00:19 UTC | |
|
Re^4: Specializing Functions with Currying
by Aristotle (Chancellor) on Aug 06, 2004 at 04:38 UTC |