Logo

Programming-Idioms

  • Smalltalk
  • C#
using System.Linq;
items = items.Prepend(x).ToList();

items implements IEnumerable<T>.
Omitting ToList() results in a wrapper IEnumerable<T> with the element prepended.
items.Insert(0, x);

items implements IList<T>.
Complexity depends on list implementation.
(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