forked from auxolotl/core
add reverseList
This commit is contained in:
parent
1462db9587
commit
df3269bfeb
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue