[Haskell-cafe] Maximum bipartite matching: 24 lines

Dmitry Olshansky olshanskydr at gmail.com
Mon Oct 29 10:08:18 CET 2012


I didn't analyze it but anytime I see "M.insertWith" I am just in doubt -
do you know about a strict version M.insertWith' ?

2012/10/24 Stefan Klinger <all-lists at stefan-klinger.de>

> On 2012-Oct-22 14:23 (-0700), Eugene Kirpichov wrote with possible
> deletions:
> >
> >     fwd = foldr (\(x,y) -> M.insertWith (++) x [y]) M.empty $ S.toList g
> >
> > Use foldl' here, foldr is absolutely useless here and it only consumes
> > the stack space as your operation is strict.
>
> Thank you very much for that.  I'll review the code under strictness
> aspects.
>
> > As for the actual code: I'd prefer the code itself to be more
> > readable, rather than have a lot of literate comments around it;
>
> I like comments documenting why something's done, complementing the code
> which tells what's done.
>
> > currently, IMO all the uncurry's, flips, eithers, maybes and
> > point-free style hurt readability heavily.
>
> I agree.  Between babbling bloated and incomprehensible terse, my code
> is certainly towards the terse extreme.  For me, that's a balancing act
> that I find hard to do right.
>
> > I'll probably try to write my own version as an exercise :)
>
> Cool!  I'd like to see that...
>
> Cheers!
> Stefan
>
>
> --
> Stefan Klinger                                      o/klettern
>                                                     /\/  bis zum
> send plaintext only - max size 32kB - no spam         \   Abfallen
> http://stefan-klinger.de
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121029/e84cf81e/attachment-0001.htm>


More information about the Haskell-Cafe mailing list