[Haskell-cafe] One question...

Waldemar Biernacki wb at sao.pl
Sun Dec 10 11:44:05 EST 2006


apflemus, Thank for your answer:

> Counter question: can you make quicksort shorter than three lines
>
>  qsort :: Ord a => [a] -> [a]
>  qsort []     = []
>  qsort (x:xs) = [y | y <- xs, y <= x] ++ [x] ++ [y | y <- xs, x < y]

The classical Perl qsort has 5 lines - more but still short :-) 
(look how similar they are, I think it is because they're recursive and have 
sub-list selectors functions ) :

######################
#!/usr/bin/perl -w

my @a = ('a',1,'c','z','h','oik','e','t','77','b');
my @b = &qqsort ( @a );
while ( @b ) { print shift @b,"\n" }

sub qqsort {
  @_ || return ();
  my $p = shift;
  return (qqsort(grep $_ lt $p, @_), $p, qqsort(grep $_ ge $p, @_));
}
######################

however, I've questioned about client - server applications - (remote SQL 
database server (postgres for instance) + users GUI + remote resources 
(file, document etc ) - that is quite different world to compare with 
the "algorithm" one. 

Are there some people who perform such applications? 
What is your experienced in them?

cheers
Waldemar


More information about the Haskell-Cafe mailing list