Hi, I struggle implementing quicksort in the nix expression language... maybe one of you gurus can help me? Here's what I have so far:
let
len = xs: builtins.length xs;
fst = xs: builtins.head xs;
lower = x: xs: builtins.filter (a: a < x) xs;
higher = x: xs: builtins.filter (a: a >= x) xs;
qs = xs:
if (0 == (len xs)) then []
else (qs (lower (fst xs) xs)) ++ (fst xs) ++ (qs (higher (fst xs)
xs));
in
qs [3 4 1 2]
Any ideas why I'm getting a stackoverflow due to infinite recursion?
--
Mit freundlichen Grüßen,
Kind regards,
Matthias Beyer
Proudly sent with mutt.
Happily signed with gnupg.
signature.asc
Description: PGP signature
_______________________________________________ nix-dev mailing list [email protected] http://lists.science.uu.nl/mailman/listinfo/nix-dev
