Improvement: Command to remove n-th element of list

Sander Tacker shared this question 11 months ago

Hi developers,

I'm wondering why there isn't a command in GeoGebra to remove the n-th element of a list. This is really annyoing!

A few years ago, Michael Borcherds postet a workaround that only workes for number lists but not for string lists or arbitrary lists (e.g. a list of lists). Additionally, Michaels solution has to be blown up even more if the length of the list is not known previously.

Other workarounds like take the sublist before the position and take the sublist after the position and then joining the sublists are also quite ugly if you want to delete several elements one after another.

Therefore, I desperately suggest to add an overloaded second syntax to the Remove Command:

Remove( <List>, <Index>)

Removes the object an the given index from the given list

Example: Remove({4,5,6,7},2) yields list {4,6,7}.

I really don't understand why this plausible command isn't implemented yet. Please approve.

Alex

1

Until (maybe) your suggestion is implemented, you can use the following remedy in the meantime:

(not as elegant as those of Michael Borcherds, but also for strings or lists and unknown lists length)

Zip(<listeINP>(n), n, (1…Länge(listeINP)) \ {<deleteIndex>, ......})

or for your example:

• l1={4,5,6,7}
• l2= Zip(l1(n),n,(1...Länge(l1))\{2})

But maybe there are even better variants.

1

@rami: Thanks for the workaround, is does the job with arbitrary lists. At least I can continue my project now!

Nevertheless I hope that the implementation of my proposed command will be seriouly considered since every programming language with lists provides a command to delete an element at a given index. I think also, an internal implementation in GeoGebra would be faster since it would avoid creating ramis "help index list".

Alex

1

una pregunta

en el comando Zip(l1(n),n,(1...Länge(l1))\{2}) hay tres puntos ...

yo siempre he usado dos puntos ..

hay una sintaxis correcta que no falle nunca o es indiferente?

PD: tambien es posible crear una herramienta personal para este comando

1

2 points est accepté, mais transformé d'office en 3 points

valide 1..5 puis regarde la définition de la liste créée, tu liras 1...5

1

merci