the_meter413
the_meter413

Reputation: 299

Tcl/sh: return elements from a nested list?

Is there a shorthand for returning elements from a nested list? Let's say I have a list defined as

%set fruits {{a apple} {b banana} {c cantaloupe} {d date}}
{a apple} {b banana} {c cantaloupe} {d date}

If, for example, I want to return the second value from the fourth nested set, is there a way to do this other than

%set myvalue [lindex [lindex $fruits 3] 1]
date

If I'm missing a man page, please include a link. I can't seem to find an answer to the above in the Tcl documentation.

Upvotes: 0

Views: 200

Answers (1)

MoDJ
MoDJ

Reputation: 4425

Yes, here is how you can do that:

% lindex $fruits {3 1}
date

Upvotes: 2

Related Questions