• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. search list and return the match list

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 150
  • Views 20273
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

search list and return the match list

wenckey
wenckey over 7 years ago

The case is like below:

I have two list like

LIST1= list("at" "ad" "ap")

LIST2=list("dad" "bad" "god" "dog" map" "lap" "glad")

What I want to do is search the LIST2 with the key word listed in LIST1, if match , ADD the match item to the new list LIST3

so for this case , the return value should be LIST3=("dad" "bad" "map" )

Anyone can give some advise or share the code?

Thanks

Kevin

  • Cancel
Parents
  • Quek
    Quek over 7 years ago

    Hi Kevin

    The following code should be ok:

    procedure( CCSflattenList(myList)
       if(listp(myList)
          mapcan('CCSflattenList myList)
          list(myList)
       ) ;if
    ) ;procedure CCSflattenList from solution 11023690


    myList1= list("at" "ad" "ap")
    myList2=list("dad" "bad" "god" "dog" "map" "lap" "glad")

    procedure( CCSgetMatchedItems(myList1 myList2)
       prog( (myList3 myList3Flat myList3Final)
          myList3=foreach( mapcar x myList1
             pcreMatchList(x myList2)
          ) ;foreach

          myList3Flat=CCSflattenList(myList3)
          myList3Final=list()
          foreach( x myList3Flat
             unless( member(x myList3Final)
                myList3Final=append1(myList3Final x)
             ) ;unless
          ) ;foreach
          return(myList3Final)
       ) ;prog
    ) ;procedure

    CCSgetMatchedItems(myList1 myList2)

    Best regards
    Quek

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to Quek

    Quek, sorry to point out that this can be done rather more concisely:

    LIST3=setof(elem LIST2
      exists(pat LIST1 index(elem pat))
    )

    this returns:

    ("dad" "bad" "map" "lap" "glad")

    Which isn't quite the same as your suggested return value (same contents as Quek's but in a different order). I think Kevin's suggestion as to the value of LIST3 has an error, unless there is some other criteria for match that you (Kevin) has not made clear.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 7 years ago in reply to Quek

    Quek, sorry to point out that this can be done rather more concisely:

    LIST3=setof(elem LIST2
      exists(pat LIST1 index(elem pat))
    )

    this returns:

    ("dad" "bad" "map" "lap" "glad")

    Which isn't quite the same as your suggested return value (same contents as Quek's but in a different order). I think Kevin's suggestion as to the value of LIST3 has an error, unless there is some other criteria for match that you (Kevin) has not made clear.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • Quek
    Quek over 7 years ago in reply to Andrew Beckett

    Hi Andrew

    This is awesome. : )  Thank you very much. I have learned a lot from your example.

    Best regards
    Quek

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information