Skip to main content
Inspiring
February 28, 2013
Answered

Remove item from numeric list

  • February 28, 2013
  • 2 replies
  • 1050 views

Lets say I have a numeric list like this.

mylist ="1,5,11,17,19"

Now I need to remove just 11 from the mylist. (delete_value = 11)

How do I  remove the delete_value from mylist

Its like the opposite of ListAppend?

So I need the new list to be ("1,5,17,19")

    This topic has been closed for replies.
    Correct answer Adam Cameron.

    That UDF should do the trick then.

    --

    Adam

    2 replies

    Tim Cunningham
    Participating Frequently
    February 28, 2013

    weezerboy, have you checked www.cflib.org for utilities that can do things like this?

    Inspiring
    February 28, 2013

    Before answering the question comprehensively, what would you expect to happen if 11 was in the list twice? Just remove the first instance of it? Or remove all instances of it?

    Basically, you can use listFind() to locate the index point at which the list item is at, then use listDeleteAt() to get rid.  You would need to continue to do this until there were not matches from the listFind() if you wanted to lose them all.

    CFLib has a UDF which does this sort of thing for you already: http://www.cflib.org/udf/ListRemoveByString

    --

    Adam

    weezerboyAuthor
    Inspiring
    February 28, 2013

    Adam,

    I would want all  instances of the value removed from the list.

    Adam Cameron.Correct answer
    Inspiring
    February 28, 2013

    That UDF should do the trick then.

    --

    Adam