Todd Hunter

Todd Hunter Todd Hunter

Niner since 2010

Comments

  • C9 Lectures: Dr. Erik Meijer - Functional Programming ​Fundamental​s, Chapter 1 of 13

    Because its what i know best, here is it in perl... 

     

    #!/usr/bin/perl sub qsort { my @array = @_; return () unless @array; my $pivot = shift @array; my @larger = (); my @smaller = (); map {$_ >= $pivot ? push @larger, $_ : push @smaller, $_} @array; return (qsort(@smaller), $pivot, qsort(@larger));
     }

     

    The question i have about the haskell version, when smaller and larger are constructed, does that walk the xs list twice to generate the two lists, or is it optimised to do it once?