http://qs1969.pair.com?node_id=386923

In the past, we've had meditaton on coroutines, continuations, haskell, and other functional topics. So I thought I'd throw my recently completed "Monads in Perl" tutorial out there for discussion. There is no real reason to use monads in perl, but hey, TMTOWTDI.


-- All code is 100% tested and functional unless otherwise noted.

Replies are listed 'Best First'.
Re: Monads in Perl
by jryan (Vicar) on Aug 31, 2004 at 17:50 UTC
    As you said, "hey, TMTOWTDI." (:
    print parse_equation("Div Div Con 18 Con 2 Con 3"); # just a sexeger sub parse_equation { my $r = reverse $_[0]; $r =~ s!(\d+(?:\.\d+)?) noC (\d+(?:\.\d+)?) noC viD! reverse($2)/reverse($1) . ' noC' !e while $r =~ /viD/; return scalar reverse $r; }
Re: Monads in Perl
by adrianh (Chancellor) on Sep 01, 2004 at 13:19 UTC

    This is nitpicking an otherwise nice little article (sorry :-) but:

    closures (also know as anonymous subroutines)

    I really wish that people wouldn't use closures and anonymous subroutines as synonyms. Not all closures are anonymous. Not all anonymous subroutines are closures.

    I know people do - but we shouldn't encourage them! It only leads to confusion.

Re: Monads in Perl
by FoxtrotUniform (Prior) on Aug 31, 2004 at 22:02 UTC

    Nice tutorial!

    Anyone else interested in joining the PerlMonks Haskell Fanboys Club? :-)

    --
    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