### The Maxima on-line user's manual

Algebra Calculator

#### Delete

Function: delete (<expr_1>, <expr_2>)

Function: delete (<expr_1>, <expr_2>, <n>) `delete(<expr_1>, <expr_2>)` removes from <expr_2> any arguments of its top-level operator which are the same (as determined by "=") as <expr_1>. Note that "=" tests for formal equality, not equivalence. Note also that arguments of subexpressions are not affected.

<expr_1> may be an atom or a non-atomic expression. <expr_2> may be any non-atomic expression. `delete` returns a new expression; it does not modify <expr_2>.

`delete(<expr_1>, <expr_2>, <n>)` removes from <expr_2> the first <n> arguments of the top-level operator which are the same as <expr_1>. If there are fewer than <n> such arguments, then all such arguments are removed.

Examples:

Removing elements from a list.

```          (%i1) delete (y, [w, x, y, z, z, y, x, w]);
(%o1)                  [w, x, z, z, x, w]```

Removing terms from a sum.

```          (%i1) delete (sin(x), x + sin(x) + y);
(%o1)                         y + x```

Removing factors from a product.

```          (%i1) delete (u - x, (u - w)*(u - x)*(u - y)*(u - z));
(%o1)                (u - w) (u - y) (u - z)```

Removing arguments from an arbitrary expression.

```          (%i1) delete (a, foo (a, b, c, d, a));
(%o1)                     foo(b, c, d)```

Limit the number of removed arguments.

```          (%i1) delete (a, foo (a, b, a, c, d, a), 2);
(%o1)                    foo(b, c, d, a)```

Whether arguments are the same as <expr_1> is determined by "=". Arguments which are `equal` but not "=" are not removed.

`          (%i1) [is (equal (0, 0)), is (equal (0, 0.0)), is (equal (0, 0b0))];`

`rat` replaced 0.0 by 0/1 = 0.0 `rat` replaced 0.0B0 by 0/1 = 0.0B0

`          (%o1)                  [true, true, true]`
`          (%i2) [is (0 = 0), is (0 = 0.0), is (0 = 0b0)];`
`          (%o2)                 [true, false, false]`
`          (%i3) delete (0, [0, 0.0, 0b0]);`
`          (%o3)                     [0.0, 0.0b0]`
`          (%i4) is (equal ((x + y)*(x - y), x^2 - y^2));`
`          (%o4)                         true`
`          (%i5) is ((x + y)*(x - y) = x^2 - y^2);`
`          (%o5)                         false`
`          (%i6) delete ((x + y)*(x - y), [(x + y)*(x - y), x^2 - y^2]);`
`                                        2    2`
`          (%o6)                       [x  - y ]`

There are also some inexact matches for `delete`. Try `?? delete` to see them.

```(%o1)                                true
(%i2) ```

### Related Examples

##### delete-lambda-sublist

a:[1,2,3,4,2,1,4,2,1];

sublist(a,lambda([x],...

delete(3,a);

Calculate

##### delete-divisors

delete(1,delete(50,di...

Calculate

##### delete-divisors

atijd :divisors(50);

atijd : delete(50,ati...

atijd : delete(1,atijd);

Calculate

##### delete-error-false-hipow-length-print-return-submatrix

equ: ut-v*vx;

eqv: vt-ux*vxx;

equx: uxt-vx^2-v*vxx;

Calculate

##### delete-sin

delete(sin(x), x+sin(...

delete(a, f(a,b,c,d,...

delete(a, f(a,b,a,c,...

Calculate

##### delete-every-full_listify-lambda-listify-makelist-map-mod-primep-set_partitions-sort-sublist

p:sublist(makelist(k,...

s:makelist([(k-mod(k,...

s:map(lambda([x],dele...

Calculate

##### delete-ifactors-member-random-true

joukko:[30, 42, 70];

luku: joukko[random(3)];

factors_only: true;

Calculate

##### delete-first-lambda-map

map(lambda([x], lambd...

Calculate

##### delete-divisors-length-random

atijd :divisors(50);

atijd : delete(50,ati...

atijd : delete(1,atijd);

Calculate

##### delete-first-length-solve

a: (7)*x^(-4)+(20)*x^...

b: solve(a);

length(b);

Calculate