Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | '\" |
2 | '\" Copyright (c) 1993 The Regents of the University of California. | |
3 | '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. | |
4 | '\" Copyright (c) 2001 Kevin B. Kenny. All rights reserved. | |
5 | '\" | |
6 | '\" See the file "license.terms" for information on usage and redistribution | |
7 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. | |
8 | '\" | |
9 | '\" RCS: @(#) $Id: lsearch.n,v 1.13.2.4 2005/01/05 21:53:30 dkf Exp $ | |
10 | '\" | |
11 | '\" The definitions below are for supplemental macros used in Tcl/Tk | |
12 | '\" manual entries. | |
13 | '\" | |
14 | '\" .AP type name in/out ?indent? | |
15 | '\" Start paragraph describing an argument to a library procedure. | |
16 | '\" type is type of argument (int, etc.), in/out is either "in", "out", | |
17 | '\" or "in/out" to describe whether procedure reads or modifies arg, | |
18 | '\" and indent is equivalent to second arg of .IP (shouldn't ever be | |
19 | '\" needed; use .AS below instead) | |
20 | '\" | |
21 | '\" .AS ?type? ?name? | |
22 | '\" Give maximum sizes of arguments for setting tab stops. Type and | |
23 | '\" name are examples of largest possible arguments that will be passed | |
24 | '\" to .AP later. If args are omitted, default tab stops are used. | |
25 | '\" | |
26 | '\" .BS | |
27 | '\" Start box enclosure. From here until next .BE, everything will be | |
28 | '\" enclosed in one large box. | |
29 | '\" | |
30 | '\" .BE | |
31 | '\" End of box enclosure. | |
32 | '\" | |
33 | '\" .CS | |
34 | '\" Begin code excerpt. | |
35 | '\" | |
36 | '\" .CE | |
37 | '\" End code excerpt. | |
38 | '\" | |
39 | '\" .VS ?version? ?br? | |
40 | '\" Begin vertical sidebar, for use in marking newly-changed parts | |
41 | '\" of man pages. The first argument is ignored and used for recording | |
42 | '\" the version when the .VS was added, so that the sidebars can be | |
43 | '\" found and removed when they reach a certain age. If another argument | |
44 | '\" is present, then a line break is forced before starting the sidebar. | |
45 | '\" | |
46 | '\" .VE | |
47 | '\" End of vertical sidebar. | |
48 | '\" | |
49 | '\" .DS | |
50 | '\" Begin an indented unfilled display. | |
51 | '\" | |
52 | '\" .DE | |
53 | '\" End of indented unfilled display. | |
54 | '\" | |
55 | '\" .SO | |
56 | '\" Start of list of standard options for a Tk widget. The | |
57 | '\" options follow on successive lines, in four columns separated | |
58 | '\" by tabs. | |
59 | '\" | |
60 | '\" .SE | |
61 | '\" End of list of standard options for a Tk widget. | |
62 | '\" | |
63 | '\" .OP cmdName dbName dbClass | |
64 | '\" Start of description of a specific option. cmdName gives the | |
65 | '\" option's name as specified in the class command, dbName gives | |
66 | '\" the option's name in the option database, and dbClass gives | |
67 | '\" the option's class in the option database. | |
68 | '\" | |
69 | '\" .UL arg1 arg2 | |
70 | '\" Print arg1 underlined, then print arg2 normally. | |
71 | '\" | |
72 | '\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $ | |
73 | '\" | |
74 | '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. | |
75 | .if t .wh -1.3i ^B | |
76 | .nr ^l \n(.l | |
77 | .ad b | |
78 | '\" # Start an argument description | |
79 | .de AP | |
80 | .ie !"\\$4"" .TP \\$4 | |
81 | .el \{\ | |
82 | . ie !"\\$2"" .TP \\n()Cu | |
83 | . el .TP 15 | |
84 | .\} | |
85 | .ta \\n()Au \\n()Bu | |
86 | .ie !"\\$3"" \{\ | |
87 | \&\\$1 \\fI\\$2\\fP (\\$3) | |
88 | .\".b | |
89 | .\} | |
90 | .el \{\ | |
91 | .br | |
92 | .ie !"\\$2"" \{\ | |
93 | \&\\$1 \\fI\\$2\\fP | |
94 | .\} | |
95 | .el \{\ | |
96 | \&\\fI\\$1\\fP | |
97 | .\} | |
98 | .\} | |
99 | .. | |
100 | '\" # define tabbing values for .AP | |
101 | .de AS | |
102 | .nr )A 10n | |
103 | .if !"\\$1"" .nr )A \\w'\\$1'u+3n | |
104 | .nr )B \\n()Au+15n | |
105 | .\" | |
106 | .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n | |
107 | .nr )C \\n()Bu+\\w'(in/out)'u+2n | |
108 | .. | |
109 | .AS Tcl_Interp Tcl_CreateInterp in/out | |
110 | '\" # BS - start boxed text | |
111 | '\" # ^y = starting y location | |
112 | '\" # ^b = 1 | |
113 | .de BS | |
114 | .br | |
115 | .mk ^y | |
116 | .nr ^b 1u | |
117 | .if n .nf | |
118 | .if n .ti 0 | |
119 | .if n \l'\\n(.lu\(ul' | |
120 | .if n .fi | |
121 | .. | |
122 | '\" # BE - end boxed text (draw box now) | |
123 | .de BE | |
124 | .nf | |
125 | .ti 0 | |
126 | .mk ^t | |
127 | .ie n \l'\\n(^lu\(ul' | |
128 | .el \{\ | |
129 | .\" Draw four-sided box normally, but don't draw top of | |
130 | .\" box if the box started on an earlier page. | |
131 | .ie !\\n(^b-1 \{\ | |
132 | \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' | |
133 | .\} | |
134 | .el \}\ | |
135 | \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' | |
136 | .\} | |
137 | .\} | |
138 | .fi | |
139 | .br | |
140 | .nr ^b 0 | |
141 | .. | |
142 | '\" # VS - start vertical sidebar | |
143 | '\" # ^Y = starting y location | |
144 | '\" # ^v = 1 (for troff; for nroff this doesn't matter) | |
145 | .de VS | |
146 | .if !"\\$2"" .br | |
147 | .mk ^Y | |
148 | .ie n 'mc \s12\(br\s0 | |
149 | .el .nr ^v 1u | |
150 | .. | |
151 | '\" # VE - end of vertical sidebar | |
152 | .de VE | |
153 | .ie n 'mc | |
154 | .el \{\ | |
155 | .ev 2 | |
156 | .nf | |
157 | .ti 0 | |
158 | .mk ^t | |
159 | \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' | |
160 | .sp -1 | |
161 | .fi | |
162 | .ev | |
163 | .\} | |
164 | .nr ^v 0 | |
165 | .. | |
166 | '\" # Special macro to handle page bottom: finish off current | |
167 | '\" # box/sidebar if in box/sidebar mode, then invoked standard | |
168 | '\" # page bottom macro. | |
169 | .de ^B | |
170 | .ev 2 | |
171 | 'ti 0 | |
172 | 'nf | |
173 | .mk ^t | |
174 | .if \\n(^b \{\ | |
175 | .\" Draw three-sided box if this is the box's first page, | |
176 | .\" draw two sides but no top otherwise. | |
177 | .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c | |
178 | .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c | |
179 | .\} | |
180 | .if \\n(^v \{\ | |
181 | .nr ^x \\n(^tu+1v-\\n(^Yu | |
182 | \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c | |
183 | .\} | |
184 | .bp | |
185 | 'fi | |
186 | .ev | |
187 | .if \\n(^b \{\ | |
188 | .mk ^y | |
189 | .nr ^b 2 | |
190 | .\} | |
191 | .if \\n(^v \{\ | |
192 | .mk ^Y | |
193 | .\} | |
194 | .. | |
195 | '\" # DS - begin display | |
196 | .de DS | |
197 | .RS | |
198 | .nf | |
199 | .sp | |
200 | .. | |
201 | '\" # DE - end display | |
202 | .de DE | |
203 | .fi | |
204 | .RE | |
205 | .sp | |
206 | .. | |
207 | '\" # SO - start of list of standard options | |
208 | .de SO | |
209 | .SH "STANDARD OPTIONS" | |
210 | .LP | |
211 | .nf | |
212 | .ta 5.5c 11c | |
213 | .ft B | |
214 | .. | |
215 | '\" # SE - end of list of standard options | |
216 | .de SE | |
217 | .fi | |
218 | .ft R | |
219 | .LP | |
220 | See the \\fBoptions\\fR manual entry for details on the standard options. | |
221 | .. | |
222 | '\" # OP - start of full description for a single option | |
223 | .de OP | |
224 | .LP | |
225 | .nf | |
226 | .ta 4c | |
227 | Command-Line Name: \\fB\\$1\\fR | |
228 | Database Name: \\fB\\$2\\fR | |
229 | Database Class: \\fB\\$3\\fR | |
230 | .fi | |
231 | .IP | |
232 | .. | |
233 | '\" # CS - begin code excerpt | |
234 | .de CS | |
235 | .RS | |
236 | .nf | |
237 | .ta .25i .5i .75i 1i | |
238 | .. | |
239 | '\" # CE - end code excerpt | |
240 | .de CE | |
241 | .fi | |
242 | .RE | |
243 | .. | |
244 | .de UL | |
245 | \\$1\l'|0\(ul'\\$2 | |
246 | .. | |
247 | .TH lsearch n 8.4 Tcl "Tcl Built-In Commands" | |
248 | .BS | |
249 | '\" Note: do not modify the .SH NAME line immediately below! | |
250 | .SH NAME | |
251 | lsearch \- See if a list contains a particular element | |
252 | .SH SYNOPSIS | |
253 | \fBlsearch \fR?\fIoptions\fR? \fIlist pattern\fR | |
254 | .BE | |
255 | ||
256 | .SH DESCRIPTION | |
257 | .PP | |
258 | This command searches the elements of \fIlist\fR to see if one | |
259 | of them matches \fIpattern\fR. If so, the command returns the index | |
260 | of the first matching element | |
261 | .VS 8.4 | |
262 | (unless the options \fB\-all\fR or \fB\-inline\fR are specified.) | |
263 | .VE 8.4 | |
264 | If not, the command returns \fB\-1\fR. The \fIoption\fR arguments | |
265 | indicates how the elements of the list are to be matched against | |
266 | \fIpattern\fR and it must have one of the following values: | |
267 | .TP | |
268 | \fB\-all\fR | |
269 | .VS 8.4 | |
270 | Changes the result to be the list of all matching indices (or all | |
271 | matching values if \fB\-inline\fR is specified as well.) | |
272 | .VE 8.4 | |
273 | .TP | |
274 | \fB\-ascii\fR | |
275 | The list elements are to be examined as Unicode strings (the name is | |
276 | for backward-compatability reasons.) This option is only meaningful | |
277 | when used with \fB\-exact\fR or \fB\-sorted\fR. | |
278 | .TP | |
279 | \fB\-decreasing\fR | |
280 | The list elements are sorted in decreasing order. This option is only | |
281 | meaningful when used with \fB\-sorted\fR. | |
282 | .TP | |
283 | \fB\-dictionary\fR | |
284 | The list elements are to be compared using dictionary-style | |
285 | comparisons (see \fBlsort\fR for a fuller description). This option | |
286 | is only meaningful when used with \fB\-exact\fR or \fB\-sorted\fR, and | |
287 | it is only distinguishable from the \fB\-ascii\fR option when | |
288 | the \fB\-sorted\fR option is given, because values are only | |
289 | dictionary-equal when exactly equal. | |
290 | .TP | |
291 | \fB\-exact\fR | |
292 | The list element must contain exactly the same string as \fIpattern\fR. | |
293 | .TP | |
294 | \fB\-glob\fR | |
295 | \fIPattern\fR is a glob-style pattern which is matched against each list | |
296 | element using the same rules as the \fBstring match\fR command. | |
297 | .TP | |
298 | \fB\-increasing\fR | |
299 | The list elements are sorted in increasing order. This option is only | |
300 | meaningful when used with \fB\-sorted\fR. | |
301 | .TP | |
302 | \fB\-inline\fR | |
303 | .VS 8.4 | |
304 | The matching value is returned instead of its index (or an empty | |
305 | string if no value matches.) If \fB\-all\fR is also specified, then | |
306 | the result of the command is the list of all values that matched. | |
307 | .VE 8.4 | |
308 | .TP | |
309 | \fB\-integer\fR | |
310 | The list elements are to be compared as integers. This option is only | |
311 | meaningful when used with \fB\-exact\fR or \fB\-sorted\fR. | |
312 | .TP | |
313 | \fB\-not\fR | |
314 | .VS 8.4 | |
315 | This negates the sense of the match, returning the index of the first | |
316 | non-matching value in the list. | |
317 | .VE 8.4 | |
318 | .TP | |
319 | \fB\-real\fR | |
320 | The list elements are to be compared as floating-point values. This | |
321 | option is only meaningful when used with \fB\-exact\fR or \fB\-sorted\fR. | |
322 | .TP | |
323 | \fB\-regexp\fR | |
324 | \fIPattern\fR is treated as a regular expression and matched against | |
325 | each list element using the rules described in the \fBre_syntax\fR | |
326 | reference page. | |
327 | .TP | |
328 | \fB\-sorted\fR | |
329 | The list elements are in sorted order. If this option is specified, | |
330 | \fBlsearch\fR will use a more efficient searching algorithm to search | |
331 | \fIlist\fR. If no other options are specified, \fIlist\fR is assumed | |
332 | to be sorted in increasing order, and to contain ASCII strings. This | |
333 | option is mutually exclusive with \fB\-glob\fR and \fB\-regexp\fR, and | |
334 | is treated exactly like \fB-exact\fR when either \fB\-all\fR, or | |
335 | \fB\-not\fR is specified. | |
336 | .TP | |
337 | \fB\-start\fR \fIindex\fR | |
338 | .VS 8.4 | |
339 | The list is searched starting at position \fIindex\fR. If \fIindex\fR | |
340 | has the value \fBend\fR, it refers to the last element in the list, | |
341 | and \fBend\-\fIinteger\fR refers to the last element in the list minus | |
342 | the specified integer offset. | |
343 | .VE 8.4 | |
344 | .PP | |
345 | If \fIoption\fR is omitted then it defaults to \fB\-glob\fR. If more | |
346 | than one of \fB\-exact\fR, \fB\-glob\fR, \fB\-regexp\fR, and | |
347 | \fB\-sorted\fR is specified, whichever option is specified last takes | |
348 | precedence. If more than one of \fB\-ascii\fR, \fB\-dictionary\fR, | |
349 | \fB\-integer\fR and \fB\-real\fR is specified, the option specified | |
350 | last takes precedence. If more than one of \fB\-increasing\fR and | |
351 | \fB\-decreasing\fR is specified, the option specified last takes | |
352 | precedence. | |
353 | ||
354 | .VS 8.4 | |
355 | .SH EXAMPLES | |
356 | .CS | |
357 | \fBlsearch\fR {a b c d e} c \fI=> 2\fR | |
358 | \fBlsearch\fR -all {a b c a b c} c \fI=> 2 5\fR | |
359 | \fBlsearch\fR -inline {a20 b35 c47} b* \fI=> b35\fR | |
360 | \fBlsearch\fR -inline -not {a20 b35 c47} b* \fI=> a20\fR | |
361 | \fBlsearch\fR -all -inline -not {a20 b35 c47} b* \fI=> a20 c47\fR | |
362 | \fBlsearch\fR -all -not {a20 b35 c47} b* \fI=> 0 2\fR | |
363 | \fBlsearch\fR -start 3 {a b c a b c} c \fI=> 5\fR | |
364 | .CE | |
365 | .VE 8.4 | |
366 | ||
367 | .SH "SEE ALSO" | |
368 | .VS 8.4 | |
369 | foreach(n), list(n), lappend(n), lindex(n), linsert(n), llength(n), | |
370 | lset(n), lsort(n), lrange(n), lreplace(n) | |
371 | .VE | |
372 | ||
373 | .SH KEYWORDS | |
374 | list, match, pattern, regular expression, search, string | |
375 | ||
376 | '\" Local Variables: | |
377 | '\" mode: nroff | |
378 | '\" End: |