From e528b920bb1fcc616179f5dbd93889ccc6b32329 Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Tue, 6 Oct 2009 13:36:46 +0000 Subject: [PATCH] Add the reverseList function. svn path=/nixpkgs/trunk/; revision=17676 --- pkgs/lib/lists.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkgs/lib/lists.nix b/pkgs/lib/lists.nix index 785e47e7d523..d032ab412bab 100644 --- a/pkgs/lib/lists.nix +++ b/pkgs/lib/lists.nix @@ -136,4 +136,10 @@ rec { zipLists = zipListsWith (fst: snd: { inherit fst snd; }); + # invert the order of the elements of a list. + reverseList = l: + let reverse_ = accu: l: + if l == [] then accu + else reverse_ ([(head l)] ++ accu) (tail l); + in reverse_ [] l; }