Programming-Idioms

New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
erase(items, x);
using System.Collections.Generic;
items.Remove(x);
import std.algorithm;
items = items.remove(items.countUntil!(a => a == x));
items.remove(x);
List.delete(items, x)
integer, dimension(:), allocatable :: items

i = findloc(items, x)
if (i /= 0) items = [items(1:i-1), items(i+1:)]
for i, y := range items {
	if y == x {
		copy(items[i:], items[i+1:])
		items[len(items)-1] = nil
		items = items[:len(items)-1]
		break
	}
}
for i, y := range items {
	if y == x {
		items = append(items[:i], items[i+1:]...)
		break
	}
}
import Data.List
delete x items
Java.utils.List
items.stream().findFirst().filter(item -> "x".equals(item)).ifPresent(removeIndex -> items.remove(removeIndex));
$list_position = array_search($x, $items);
$specific_item = $items[$position];
unset($specific_item);
uses classes;
i := items.IndexOf(x);
if i <> -1 then
  items.delete(i);
use List::UtilsBy qw(extract_first_by);
extract_first_by { $x eq $_ } @items;
items.remove(x)
i = items.index(x)
items.delete_at(i) unless i.nil?
if let Some(i) = items.first(&x) {
    items.remove(i);
}