Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » lists and sequences » delete
next | previous | forward | backward | up | index | toc

# delete -- delete some elements of a list

- Usage:
    `delete(x, A)`
- Inputs:
  - A, list or sequence
  - x, thing
- Outputs:
  - A2, a new list from A with every occurrence of x removed

## Description

    i1 : delete(c, {a,b,c,d,e,a,b,c,d,e})

    o1 = {a, b, d, e, a, b, d, e}

    o1 : List

Equality is determined with ===, which is quick, but not always intuitive. For instance, in the next example, the first item in the list is not removed, because it is an element of QQ and will not match an element of ZZ.

    i2 : delete(1, {2/2, 3/2, 4/2})

             3
    o2 = {1, -, 2}
             2

    o2 : List

To delete items from a list by index, rather than value, see drop.

## See also

- drop -- drop some elements from a list or sequence
- positions -- which elements of a list satisfy a condition
- select -- select from a list, hash table, or string
- lists and sequences -- a detailed overview of lists and sequences in Macaulay2

## Ways to use delete:

- `delete(Thing,BasicList)`

## For the programmer

The object delete is a method function.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/functions/delete-doc.m2:37:0.