query
On this page

reverseList

lib.lists.reverseList

Docs pulled from | This Revision | 24 minutes ago


Nixpkgs manual

Reverse the order of the elements of a list.

Inputs

xs

1. Function argument

Type

reverseList :: [a] -> [a]

Examples

lib.lists.reverseList usage example

reverseList [ "b" "o" "j" ]
=> [ "j" "o" "b" ]

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

reverseList =
    xs:
    let
      # subtract one to save an __sub call on every element
      lastIndex = length xs - 1;
    in
    genList (n: elemAt xs (lastIndex - n)) (lastIndex + 1);