Qu

pop_back

Builtin index · Collections & strings

result = pop_front(l)

Input: l · Output: result

What it is

l is a linked_list handle. Removes and returns the element from the front (pop_front) or back (pop_back) in O(1). to_vec turns the result back into an ordinary List.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = pop_front(l)
l Listnot documented yet
result —
Returns the removed element itself, whatever type was pushed; the list is one shorter afterwards.

Examples

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

l = linked_list()
l.push_back(1)
l.push_back(2)
l.push_front(0)
print(l.to_vec())   # (0, 1, 2)

print(pop_front(l)) # 0 -- removes from the front

print(pop_back(l))  # 2 -- removes from the back

print(l.to_vec())   # (1) -- what's left

output
(0, 1, 2)
0
2
(1)

from collections-strings

How it works

linked_list() (§ data structures pass, 2026-09-01, that module's own doc comment for why VecDeque rather than a real boxed-node chain.

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

See also

pop_front — documented in the same entry.