metaperl has asked for the wisdom of the Perl Monks concerning the following question:
Now, I want to curry string equal so that my function morf returns 'Male' if the $testval is 'M' and otherwise female:sub morf { my($tester, $testval, $true_word, $false_word)=@_; $tester->($testval) ? $true_word : $false_word ; }
sub se { my ($val) = @_; sub { $_[0] eq $val } ; }
How can this be done?morf(se('M'), $driver->{gender}, 'Male', 'Female') ;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: currying CORE functions into closures?
by roboticus (Chancellor) on May 01, 2009 at 22:35 UTC | |
Re: currying CORE functions into closures?
by revdiablo (Prior) on May 01, 2009 at 21:13 UTC |