diff --git a/nodes/1_lib/source/detangled/1_foundation.nix b/nodes/1_lib/source/detangled/1_foundation.nix index 735f03a..1898b5b 100644 --- a/nodes/1_lib/source/detangled/1_foundation.nix +++ b/nodes/1_lib/source/detangled/1_foundation.nix @@ -63,6 +63,35 @@ let fold' 0 ); + /** + Reverse the order of the elements of a list. + + # Inputs + + `xs` + + : 1\. Function argument + + # Type + + ``` + reverseList :: [a] -> [a] + ``` + + # Examples + :::{.example} + ## `lib.lists.reverseList` usage example + + ```nix + reverseList [ "b" "o" "j" ] + => [ "j" "o" "b" ] + ``` + + ::: + */ + reverseList = xs: + let l = builtins.length xs; in builtins.genList (n: builtins.elemAt xs (l - n - 1)) l; + /** Check whether something is a function or something annotated with function args. @@ -156,6 +185,7 @@ in { loadStatic = loadStatic; foldr = foldr; + reverseList = reverseList; isFunction = isFunction; functionArgs = functionArgs; setFunctionArgs = setFunctionArgs;