Hello!
I try to remove random elements from a list until the list is
empty. My environment is Allegro Lisp , free edition.
after some repetitions , the output of sequential calls to delete (and
the content of set1) start to look like this
that is, sometimes items are not deleted, sometimes deleted items
reappear. If I use remove there is no such problem.
Is this a bug or do I miss something about delete ?
Hello!
I try to remove random elements from a list until the list is empty.
My environment is Allegro Lisp , free edition.
(setq set1 '(Nr1 Nr2 Nr3))
(delete (nth (random (length set1)) set1) set1)
after some repetitions , the output of sequential calls to delete (and
the content of set1) start to look like this
(NR1 NR2 NR3)
(NR2 NR3)
(NR1 NR2)
(NR1)
NIL
that is, sometimes items are not deleted, sometimes deleted items reappear. If I use remove there is no such problem.
Is this a bug or do I miss something about delete ?
Hello!
I try to remove random elements from a list until the list is empty. My environment is Allegro Lisp , free edition.
(setq set1 '(Nr1 Nr2 Nr3))
(delete (nth (random (length set1)) set1) set1)
Don't you do it like this when you use REMOVE ?Yes, I did so when using remove but not with delete, because I misunderstood the nature of variable set1. It is clear to me now.
The two previous answers so far are (almost) correct, but will not make the real issue clear to a beginner...
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 298 |
Nodes: | 16 (2 / 14) |
Uptime: | 26:11:03 |
Calls: | 6,680 |
Calls today: | 3 |
Files: | 12,222 |
Messages: | 5,342,184 |
Posted today: | 2 |