Format

length(E)

Returns

The length of the data associated with E.

Args

E: text, list, file, or vector

world << length("Hi")

This outputs, “2”, the length of the string “Hi”.

world << length(list(1,2,3))

This outputs, “3”, the length of the list.

world << length(file("test.txt"))

This outputs the length of the file.

Note

In strings containing non-ASCII characters, this is the length in bytes, not characters; a character may span multiple bytes. Use length_char() to work with character counts instead of bytes. See the Unicode section for more information.

For vectors, the length is the order of the vector, as in 2 for a 2D vector or 3 for a 3D vector. See vector.len.

See also