• 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. SKILL equivalent of TCL "splatter" operator

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 143
  • Views 1774
  • 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

SKILL equivalent of TCL "splatter" operator

liorscotland
liorscotland over 9 years ago

Hello all. Let us assume the we have a list list1, of 2 elements. I need to feed those 2 elements as separate arguments to a proc, say proc1.
What that I would do in skill is:
proc1(   car(list1) cadr( list2  )
In TCL, I would do this:
proc1 [ lindex $list1 0] [lindex $list1 1]
or... Us the splatter operator:
proc1 {*}$list1
Naturally, the 2nd way is easier, and scalable, whereas the 1st way is not scalable, if proc1 can accept an arbitrary number of arguments.
Is there a way to achieve the same in SKILL?
Thanks.

  • Cancel
  • skillUser
    skillUser over 9 years ago
    Hi Lior,

    Interesting - I'm not familiar with the 'splatter' operator in Tcl (and I know Tcl pretty well), but the way to do this in SKILL is to use the apply function: apply('proc1 list1).

    E.g. apply('plus list(1 2 3)) => 6

    Hopefully this does what you want. BTW, I'm assuming that the 'list2' above is a typo.

    Best regards,
    Lawrence.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • liorscotland
    liorscotland over 9 years ago
    It is a typo.
    Thanks, They need to make the documentation a little clearer. I actually looked at this function, and did not understand it. BTW, Splatter is the fastest way in Tcl (until 8.6) to append 2 lists together. I.e. Let us say that you have list1 and list2. You want to add list2 to list 1, in a way that the length of list1 is the length of list1 + the length of list2, and not having 1 more element in list1, which is list2. There are 2 ways to do that:
    1. foreach elem $list2 { lappend list1 $elem }
    2. lappend list1 {*}$list2
    The second option will run faster. Ruby has it too.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    Lior,

    This was also covered in the advanced SKILL course in a section on lambda, apply and funcall.

    I think the documentation is fairly clear if you look at the examples, although whether you'd find it just by keyword searching I'm less sure!

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • liorscotland
    liorscotland over 9 years ago
    Hi Andrew.
    I did the keyword search. I remembered something about that, but the labs were out of my reach.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 9 years ago

    Hi Lior,

    I'm only teasing ;-)

    Obviously big languages like Tcl have the benefit of many more resources (such as stackoverflow) which help to answer such questions. However, this is one of those things that require your muscle memory to be trained when you're using a language - then they become natural.

    That said, a google search for "skill call function with list of arguments" finds (a handful of hits down) one of Jim's blogs

    Team SKILL
    SKILL for the Skilled: Part 2, Many Ways to Sum a List
    In the previous posting, SKILL for the Skilled: Many Ways to Sum a List (Part 1 ) , I showed a couple of ways to arithmetically sum up a given list of numbers. In particular, I presenting the following…
    By Team SKILL over 13 years ago in Cadence Blogs > Analog/Custom Design

    which mentions apply for this - in fact it's covered in more detail in part 1 (linked to from that, of course) which also leads to this general Wikipedia reference as apply is used in many languages based on lambda calculus.

    What's even more amusing is the reference to Tcl on that wikipedia page:

    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