Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #226 Delete last element from list

Remove the last element from the list items.

import static java.util.Arrays.copyOfRange;
items = copyOfRange(items, 0, items.length - 1);
import static java.lang.System.arraycopy;
int n, t[] = new int[n = items.length - 1];
arraycopy(items, 0, t, 0, n);
items = t;
items.removeLast();
import java.util.List;
items.remove(items.size() - 1);
with Ada.Containers.Vectors;
Items.Delete_Last (Count => 1);
(drop-last items)
items.pop_back();
items.RemoveAt(items.Count - 1);
items.removeLast();
items = items(1:size(items)-1)
import "slices"
items = slices.Delete(items, len(items)-1, len(items))
items = items[:len(items)-1]
pop :: [a] -> [a]
pop [] = []
pop xs = init xs

let items2 = pop items
let items2 = init items
items.pop();
array_pop($items);
uses Classes;
items.delete(items.count-1);
pop(@items);
items.pop()
items.pop
items.pop();

New implementation...
< >
programming-idioms.org