query
On this page

length

lib.length

Primop
Docs pulled from | This Revision | 16 minutes ago


Nix manual

Takes 1 arguments

e

Return the length of the list e.

Time Complexity

O(1)

Noogle detected

Aliases

Detected Type
length :: [a] -> Int

Implementation

This function is implemented in c++ and is part of the native nix runtime.

src/libexpr/primops.cc:3947

static void prim_length(EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
    state.forceList(*args[0], pos, "while evaluating the first argument passed to builtins.length");
    v.mkInt(args[0]->listSize());
}