in reply to Re: RFC: A Perlesque Introduction to Haskell, Part One (draft)
in thread RFC: A Perlesque Introduction to Haskell, Part One (DRAFT)
As for pattern-matching, the absolute coolest demonstration of this is quicksort in 2 or 3 lines of Haskell
Just for the fun of it, and for comparision, here is what (I think) the equivalent perl would be (for numeric sorts, I don't know if Haskell has a separate character comparision operator like Perl):
It can be done without the $x temp variable and the shift (saving one line), but then it's less readable IMO.sub qs { return unless @_; my $x = shift; return qs(grep($_ < $x, @_)), $x, qs(grep($_ >= $x, @_)); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: RFC: A Perlesque Introduction to Haskell, Part One (draft)
by Errto (Vicar) on Jun 24, 2004 at 01:29 UTC | |
Re^3: RFC: A Perlesque Introduction to Haskell, Part One (draft)
by ihb (Deacon) on Jun 24, 2004 at 02:28 UTC |
In Section
Meditations