• 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. How to convert a string to a list

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 17082
  • 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

How to convert a string to a list

Annaliza
Annaliza over 6 years ago

Hi, 

I'm new to skill programming. I just want to know if there is already an existing function that I could use to convert string to a list.

I cannot seem to use parseString since I only have a single word.

This is what I want to do:

Convert this string "A1" into `(A1)

Thanks for the help!

Regards,

Anna

  • Cancel
  • skillUser
    skillUser over 6 years ago

    Hi Anna,

    Do you really want it as a list, perhaps you might want it as just a symbol?  Anyway, the following will do what you want:

    theString = "A1"
    list(stringToSymbol(theString)) => (A1)

    By the way the backquote (`) has a special meaning and is different to the quote ('), normally one would use a single quote to obtain a literal without any evaluation (the backquote allows selective evaluation and so to avoid confusion I would limit its use to the cases where it is being used for that purpose).

    Hopefully this will help you.

    Best regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Annaliza
    Annaliza over 6 years ago in reply to skillUser

    Hi Lawrence,

    Thanks! That will work.

    You're right. I just mis-used the backquote (`), that should be quote (') to make it as a list.

    I just have another question on how I could concatenate the list in a single list?

    For example, I have this list of symbols that is being generated in a loop.

    In another procedure, I need it to be like this:

    list('(A1) '(A2) '(B1) '(B24) '(C1) '(C2))

    I want to know how I could store the result in each loop, then concatenate all in a single list.

    Thanks,

    Anna

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 6 years ago in reply to Annaliza

    Hi Anna,

    Several ways:

    listOfBumps=nil
    foreach(loopVar ...
      bumpList=list(stringToSymbol(...))
      listOfBumps=cons(bumpList listOfBumps)
    )

    The list will be in reverse order. You could reverse it using the reverse() function at the end if the order matters (or don't bother if the order is irrelevant). You could use tconc to construct the list in order, but that's a bit more complicated (not very, but I don't want to confuse you).

    If the list you are processing has a one to one correspondence with the output list (i.e. you are dealing with a list of something that you're processing, and every single one has a "bump" list), then:

    listOfBumps=foreach(mapcar loopVar ...
      ... do whatever you need to ...
      ; final thing in loop is what gets added into resulting list
      list(stringToSymbol(...))
    )

    This is all a bit of a guess, because you didn't give much info as to what your loop is doing.

    Regards,

    Andrew

    • 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