{"id":6286,"date":"2022-12-20T18:58:06","date_gmt":"2022-12-20T21:58:06","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/array-mann\/"},"modified":"2022-12-20T18:58:06","modified_gmt":"2022-12-20T21:58:06","slug":"array-mann","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/array-mann\/","title":{"rendered":"array (mann)"},"content":{"rendered":"<h1 align=\"center\">array<\/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\">array \u2212 Manipulate array variables<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>array<\/b> <i>option arrayName<\/i> ?<i>arg arg &#8230;<\/i>? ______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This command performs one of several operations on the variable given by <i>arrayName<\/i>. Unless otherwise specified for individual commands below, <i>arrayName<\/i> must be the name of an existing array variable. The <i>option<\/i> argument determines what action is carried out by the command. The legal <i>options<\/i> (which may be abbreviated) are: <b><br \/> array anymore<\/b> <i>arrayName searchId<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns 1 if there are any more elements left to be processed in an array search, 0 if all elements have already been returned. <i>SearchId<\/i> indicates which search on <i>arrayName<\/i> to check, and must have been the return value from a previous invocation of <b>array startsearch<\/b>. This option is particularly useful if an array has an element with an empty name, since the return value from <b>array nextelement<\/b> will not indicate whether the search has been completed.<\/p>\n<p style=\"margin-left:11%;\"><b>array donesearch<\/b> <i>arrayName searchId<\/i><\/p>\n<p style=\"margin-left:22%;\">This command terminates an array search and destroys all the state associated with that search. <i>SearchId<\/i> indicates which search on <i>arrayName<\/i> to destroy, and must have been the return value from a previous invocation of <b>array startsearch<\/b>. Returns an empty string.<\/p>\n<p style=\"margin-left:11%;\"><b>array exists<\/b> <i>arrayName<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns 1 if <i>arrayName<\/i> is an array variable, 0 if there is no variable by that name or if it is a scalar variable.<\/p>\n<p style=\"margin-left:11%;\"><b>array get<\/b> <i>arrayName<\/i> ?<i>pattern<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Returns a list containing pairs of elements. The first element in each pair is the name of an element in <i>arrayName<\/i> and the second element of each pair is the value of the array element. The order of the pairs is undefined. If <i>pattern<\/i> is not specified, then all of the elements of the array are included in the result. If <i>pattern<\/i> is specified, then only those elements whose names match <i>pattern<\/i> (using the matching rules of <b>string match<\/b>) are included. If <i>arrayName<\/i> is not the name of an array variable, or if the array contains no elements, then an empty list is returned. If traces on the array modify the list of elements, the elements returned are those that exist both before and after the call to <b>array get<\/b>.<\/p>\n<p style=\"margin-left:11%;\"><b>array names<\/b> <i>arrayName<\/i> ?<i>mode<\/i>? ?<i>pattern<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Returns a list containing the names of all of the elements in the array that match <i>pattern<\/i>. <i>Mode<\/i> may be one of <b>\u2212exact<\/b>, <b>\u2212glob<\/b>, or <b>\u2212regexp<\/b>. If specified, <i>mode<\/i> designates which matching rules to use to match <i>pattern<\/i> against the names of the elements in the array. If not specified, <i>mode<\/i> defaults to <b>\u2212glob<\/b>. See the documentation for <b>string match<\/b> for information on glob style matching, and the documentation for <b>regexp<\/b> for information on regexp matching. If <i>pattern<\/i> is omitted then the command returns all of the element names in the array. If there are no (matching) elements in the array, or if <i>arrayName<\/i> is not the name of an array variable, then an empty string is returned.<\/p>\n<p style=\"margin-left:11%;\"><b>array nextelement<\/b> <i>arrayName searchId<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns the name of the next element in <i>arrayName<\/i>, or an empty string if all elements of <i>arrayName<\/i> have already been returned in this search. The <i>searchId<\/i> argument identifies the search, and must have been the return value of an <b>array startsearch<\/b> command. Warning: if elements are added to or deleted from the array, then all searches are automatically terminated just as if <b>array donesearch<\/b> had been invoked; this will cause <b>array nextelement<\/b> operations to fail for those searches.<\/p>\n<p style=\"margin-left:11%;\"><b>array set<\/b> <i>arrayName list<\/i><\/p>\n<p style=\"margin-left:22%;\">Sets the values of one or more elements in <i>arrayName<\/i>. <i>list<\/i> must have a form like that returned by <b>array get<\/b>, consisting of an even number of elements. Each odd-numbered element in <i>list<\/i> is treated as an element name within <i>arrayName<\/i>, and the following element in <i>list<\/i> is used as a new value for that array element. If the variable <i>arrayName<\/i> does not already exist and <i>list<\/i> is empty, <i>arrayName<\/i> is created with an empty array value.<\/p>\n<p style=\"margin-left:11%;\"><b>array size<\/b> <i>arrayName<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns a decimal string giving the number of elements in the array. If <i>arrayName<\/i> is not the name of an array then 0 is returned.<\/p>\n<p style=\"margin-left:11%;\"><b>array startsearch<\/b> <i>arrayName<\/i><\/p>\n<p style=\"margin-left:22%;\">This command initializes an element-by-element search through the array given by <i>arrayName<\/i>, such that invocations of the <b>array nextelement<\/b> command will return the names of the individual elements in the array. When the search has been completed, the <b>array donesearch<\/b> command should be invoked. The return value is a search identifier that must be used in <b>array nextelement<\/b> and <b>array donesearch<\/b> commands; it allows multiple searches to be underway simultaneously for the same array. It is currently more efficient and easier to use either the <b>array get<\/b> or <b>array names<\/b>, together with <b>foreach<\/b>, to iterate over all but very large arrays. See the examples below for how to do this.<\/p>\n<p style=\"margin-left:11%;\"><b>array statistics<\/b> <i>arrayName<\/i><\/p>\n<p style=\"margin-left:22%;\">Returns statistics about the distribution of data within the hashtable that represents the array. This information includes the number of entries in the table, the number of buckets, and the utilization of the buckets.<\/p>\n<p style=\"margin-left:11%;\"><b>array unset<\/b> <i>arrayName<\/i> ?<i>pattern<\/i>?<\/p>\n<p style=\"margin-left:22%;\">Unsets all of the elements in the array that match <i>pattern<\/i> (using the matching rules of <b>string match<\/b>). If <i>arrayName<\/i> is not the name of an array variable or there are no matching elements in the array, no error will be raised. If <i>pattern<\/i> is omitted and <i>arrayName<\/i> is an array variable, then the command unsets the entire array. The command always returns an empty string.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>array set<\/b> colorcount { <br \/> red 1 <br \/> green 5 <br \/> blue 4 <br \/> white 9 <br \/> }<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">foreach {color count} [<b>array get<\/b> colorcount] { <br \/> puts &#8220;Color: $color Count: $count&#8221; <br \/> } <b><br \/> \u2192<\/b> Color: blue Count: 4 <br \/> Color: white Count: 9 <br \/> Color: green Count: 5 <br \/> Color: red Count: 1<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">foreach color [<b>array names<\/b> colorcount] { <br \/> puts &#8220;Color: $color Count: $colorcount($color)&#8221; <br \/> } <b><br \/> \u2192<\/b> Color: blue Count: 4 <br \/> Color: white Count: 9 <br \/> Color: green Count: 5 <br \/> Color: red Count: 1<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">foreach color [lsort [<b>array names<\/b> colorcount]] { <br \/> puts &#8220;Color: $color Count: $colorcount($color)&#8221; <br \/> } <b><br \/> \u2192<\/b> Color: blue Count: 4 <br \/> Color: green Count: 5 <br \/> Color: red Count: 1 <br \/> Color: white Count: 9<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>array statistics<\/b> colorcount <b><br \/> \u2192<\/b> 4 entries in table, 4 buckets <br \/> number of buckets with 0 entries: 1 <br \/> number of buckets with 1 entries: 2 <br \/> number of buckets with 2 entries: 1 <br \/> number of buckets with 3 entries: 0 <br \/> number of buckets with 4 entries: 0 <br \/> number of buckets with 5 entries: 0 <br \/> number of buckets with 6 entries: 0 <br \/> number of buckets with 7 entries: 0 <br \/> number of buckets with 8 entries: 0 <br \/> number of buckets with 9 entries: 0 <br \/> number of buckets with 10 or more entries: 0 <br \/> average search distance for entry: 1.2<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">list(n), string(n), variable(n), trace(n), foreach(n)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">array, element names, search<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  array \u2212 Manipulate array variables <\/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":[2892,2635],"class_list":["post-6286","post","type-post","status-publish","format-standard","hentry","category-n-comandos-tcl-tk","category-sin-categoria","tag-array","tag-mann"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6286","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=6286"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6286\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}