Pathologically Eclectic Rubbish Lister | |
PerlMonks |
RFC: Monads in Perl (Send + More = Money)by LanX (Saint) |
on Dec 02, 2020 at 18:10 UTC ( [id://11124522]=perlmeditation: print w/replies, xml ) | Need Help?? |
One of the attendants at German.pm online meeting yesterday pointed to these blogposts of MJ Dominus somehow complaining
that Perl is too "clumsy" to reimplement a Haskell solution based on monads see
Let's say for concreteness that we would like to solve this cryptarithm puzzle:This means that we want to map the letters S, E, N, D, M, O, R, Y to distinct digits 0 through 9 to produce a five-digit and two four-digit numerals which, when added in the indicated way, produce the indicated sum. the proposed Perl code was actually the semantic translation of some Python code and was indeed clumsy (NB all those curlies at the end)
<Reveal this spoiler or all in this thread> Now here my solution reusing some work I've done in the past with List Comprehensions
NB: It could be done better and faster, I've just coded this POC from scratch within an hour. Please note that making it "lazy" is not really a problem, left for the interested reader. So Monads in Perl are not that complicated ... or what am I missing? ;-)
Cheers Rolf
Back to
Meditations
|
|