Home > Community > Forums > Custom IC SKILL > How to Remove multiple objects from a list

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 How to Remove multiple objects from a list 

Last post Mon, Jan 18 2010 3:40 PM by Quek. 1 replies.
Started by posh 18 Jan 2010 03:16 PM. Topic has 1 replies and 791 views
Page 1 of 1 (2 items)
Sort Posts:
  • Mon, Jan 18 2010 3:16 PM

    • posh
    • Not Ranked
    • Joined on Thu, Dec 31 2009
    • Posts 12
    • Points 240
    How to Remove multiple objects from a list Reply

    Hi

    I have a problem writing skill to eliminate repetitions of an object in a list.

    For Example if i have a list list1 = '(a a b b c a c b a c d a )

    i have to get an output as list1=(a b c d) for this i have trying to use for loops but all my tries are just returning nil. can anyone please help me how to do this.

    Thank You

    Regards

    Harish

    • Post Points: 20
  • Mon, Jan 18 2010 3:40 PM

    • Quek
    • Top 10 Contributor
    • Joined on Wed, Oct 14 2009
    • Singapore, 00-SG
    • Posts 1,060
    • Points 16,110
    Re: How to Remove multiple objects from a list Reply
    Hi Harish

    I think perhaps you can do something like this:

    list1='(a a b b c a c b a c d a)
    cleanList='()
    foreach(x list1
       unless( member(x cleanList)
          cleanList=cons(x cleanList)
       ) ;unless
    ) ;foreach
    printf("cleanList : %L\n" cleanList)

    I am doing it the straight-forward way. Maybe someone else has a better method. : )

    Best regards
    Quek
    • Post Points: 5
Page 1 of 1 (2 items)
Sort Posts:
Started by posh at 18 Jan 2010 03:16 PM. Topic has 1 replies.