# [Maxima] Maxima lists and the delete function

Robyn Dawn Hannigan sonofthejedi at xtra.co.nz
Sun Mar 22 03:51:49 CDT 2009

```Dear Maxima Developers,

As another new user facing the same problem over the usage of the delete
operator, in a list, i here post the following trivial example of its
attempted use.

In the construction of a simple Sieve of Eurastothenes for finding
primes below an integer x, one approach is to construct a list of
possible primes, then delete obvious non-primes. Here we go with the
problenm then.
(%i54) allprimes(x) := block(
[
max:x,
smax:x^(1/2),
cands:[]
],
cands:makelist(x,x,1,max),
for i:1 while i < smax do block(
print(i),
print(cands),
print(args(cands)),
delete(i,cands),
print(cands)
)
)\$

(%i56) allprimes(10);
1
[1,2,3,4,5,6,7,8,9,10]
[1,2,3,4,5,6,7,8,9,10]
[1,2,3,4,5,6,7,8,9,10]
2
[1,2,3,4,5,6,7,8,9,10]
[1,2,3,4,5,6,7,8,9,10]
[1,2,3,4,5,6,7,8,9,10]
3
[1,2,3,4,5,6,7,8,9,10]
[1,2,3,4,5,6,7,8,9,10]
[1,2,3,4,5,6,7,8,9,10]
(%o56) done

What i am trying to do is delete the value i, which in each iteration
of the for is bound to an integer, which value one may see printed in
the output.

What am i missing?

```