Logo

Programming-Idioms

  • C
  • Vb
items.Insert(0, x)

items implements IList<T>.
Complexity depends on list implementation.
Imports System.Linq
items = items.Prepend(x).ToList()

items implements IEnumerable<T>.
Omitting ToList() results in a wrapper IEnumerable<T> with the element prepended.
(def items2 (conj items x))

conj take a list and an item, in that order, and appends the item to the list at the front.

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