{"id":6178,"date":"2022-12-20T18:58:00","date_gmt":"2022-12-20T21:58:00","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/lindex-mann\/"},"modified":"2022-12-20T18:58:00","modified_gmt":"2022-12-20T21:58:00","slug":"lindex-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/lindex-mann\/","title":{"rendered":"lindex (mann)"},"content":{"rendered":"<h1 align=\"center\">lindex<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">lindex \u2212 Retrieve an element from a list<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>lindex<\/b> <i>list ?index &#8230;?<\/i> ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>lindex<\/b> command accepts a parameter, <i>list<\/i>, which it treats as a Tcl list. It also accepts zero or more <i>indices<\/i> into the list. The indices may be presented either consecutively on the command line, or grouped in a Tcl list and presented as a single argument.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If no indices are presented, the command takes the form:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>lindex<\/b> <i>list<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">or<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>lindex<\/b> <i>list<\/i> {}<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">In this case, the return value of <b>lindex<\/b> is simply the value of the <i>list<\/i> parameter.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">When presented with a single index, the <b>lindex<\/b> command treats <i>list<\/i> as a Tcl list and returns the <i>index<\/i>\u2019th element from it (0 refers to the first element of the list). In extracting the element, <b>lindex<\/b> observes the same rules concerning braces and quotes and backslashes as the Tcl command interpreter; however, variable substitution and command substitution do not occur. If <i>index<\/i> is negative or greater than or equal to the number of elements in <i>value<\/i>, then an empty string is returned. The interpretation of each simple <i>index<\/i> value is the same as for the command <b>string index<\/b>, supporting simple index arithmetic and indices relative to the end of the list.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">If additional <i>index<\/i> arguments are supplied, then each argument is used in turn to select an element from the previous indexing operation, allowing the script to select elements from sublists. The command,<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>lindex<\/b> $a 1 2 3<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">or<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>lindex<\/b> $a {1 2 3}<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">is synonymous with<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>lindex<\/b> [<b>lindex<\/b> [<b>lindex<\/b> $a 1] 2] 3<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Lists can be indexed into from either end:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>lindex<\/b> {a b c} 0 <i><br \/> \u2192 a<\/i> <b><br \/> lindex<\/b> {a b c} 2 <i><br \/> \u2192 c<\/i> <b><br \/> lindex<\/b> {a b c} end <i><br \/> \u2192 c<\/i> <b><br \/> lindex<\/b> {a b c} end-1 <i><br \/> \u2192 b<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Lists or sequences of indices allow selection into lists of lists:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>lindex<\/b> {a b c} <i><br \/> \u2192 a b c<\/i> <b><br \/> lindex<\/b> {a b c} {} <i><br \/> \u2192 a b c<\/i> <b><br \/> lindex<\/b> {{a b c} {d e f} {g h i}} 2 1 <i><br \/> \u2192 h<\/i> <b><br \/> lindex<\/b> {{a b c} {d e f} {g h i}} {2 1} <i><br \/> \u2192 h<\/i> <b><br \/> lindex<\/b> {{{a b} {c d}} {{e f} {g h}}} 1 1 0 <i><br \/> \u2192 g<\/i> <b><br \/> lindex<\/b> {{{a b} {c d}} {{e f} {g h}}} {1 1 0} <i><br \/> \u2192 g<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">List indices may also perform limited computation, adding or subtracting fixed amounts from other indices:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">set idx 1 <b><br \/> lindex<\/b> {a b c d e f} $idx+2 <i><br \/> \u2192 d<\/i> <br \/> set idx 3 <b><br \/> lindex<\/b> {a b c d e f} $idx+2 <i><br \/> \u2192 f<\/i><\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">list(n), lappend(n), linsert(n), llength(n), lsearch(n), lset(n), lsort(n), lrange(n), lreplace(n), string(n)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">element, index, list<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  lindex \u2212 Retrieve an element from a list <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3783,1],"tags":[2817,2635],"class_list":["post-6178","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-lindex","tag-mann"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6178"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6178\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}