Qu

tail

Builtin index · Collections & strings

result = head(s, n)

Input: s, n · Output: result

What it is

s is a Str, List, Vec, or Table; n (number, default 5 when used on a table).

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = head(s, n)
s Str, List, Vec, or Tables is a Str, List, Vec, or Table.
n numbern (number, default 5 when used on a table).
result —
Returns the first (head) or last (tail) n elements/rows, same type as s.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

print(tail("abcdefgh", 3))    # "fgh"

log = "INFO start\nERROR disk full\nINFO retry\nERROR timeout"
print(grep(log, "ERROR"))     # ("ERROR disk full", "ERROR timeout")

output
fgh
("ERROR disk full", "ERROR timeout")

from collections-strings

How it works

head/tail of the first thing you reach for them with. A table was the only one they took, so head(s, 2) on a string -- the obvious spelling -- was an error naming tables.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.

See also

head — documented in the same entry.