Skip to main content
Inspiring
Feb 28, 2013 8:31 PM UTC
Answered

Remove item from numeric list

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 is closed to new replies. Start a new post to keep the conversation going.
    Adam Cameron.Correct answer
    Inspiring
    Feb 28, 2013 9:03 PM UTC

    That UDF should do the trick then.

    --

    Adam

    5 replies

    Tim Cunningham
    Participating Frequently
    Feb 28, 2013 8:52 PM UTC

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

    Translate
    Inspiring
    Feb 28, 2013 8:37 PM UTC

    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

    Translate
    weezerboyAuthor
    Inspiring
    Feb 28, 2013 8:39 PM UTC

    Adam,

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

    Translate
    Adam Cameron.Correct answer
    Inspiring
    Feb 28, 2013 9:03 PM UTC

    That UDF should do the trick then.

    --

    Adam

    Translate