string 2 list

Discussion in 'Cadence' started by sg, Jul 10, 2011.

  1. sg

    sg Guest

    Hello Guys,

    I have a string value which is indeed a list of lists, is there any
    way to convert it to list.

    e.g.,

    value = "((\"a\" (1 2 4)) (\"b\" (3 6 7)))"

    what is best way to process this string as list as:

    value = '(("a" (1 2 4)) ("b" (3 6 7)))

    such I can use all list operation like assoc, car etc on this value?
     
    sg, Jul 10, 2011
    #1
  2. sg

    sg Guest

    hmmm...., I saw one of earlier q/a, linereadstring is the routine to
    do so. Thanks, ::)
     
    sg, Jul 10, 2011
    #2
  3. sg

    Pete Z. Guest

    I don't know if this is the best way, but:

    MyVal = "((\"a\" (1 2 4)) (\"b\" (3 6 7)))"
    MyList = evalstring(strcat("'" MyVal))

    works for this particular example.

    -Pete Z.
     
    Pete Z., Jul 19, 2011
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.