[25] | 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 <kennykb@acm.org>. 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: linsert.n,v 1.14 2008/03/26 09:59:22 dkf Exp $ |
---|
| 10 | '\" |
---|
| 11 | .so man.macros |
---|
| 12 | .TH linsert n 8.2 Tcl "Tcl Built-In Commands" |
---|
| 13 | .BS |
---|
| 14 | '\" Note: do not modify the .SH NAME line immediately below! |
---|
| 15 | .SH NAME |
---|
| 16 | linsert \- Insert elements into a list |
---|
| 17 | .SH SYNOPSIS |
---|
| 18 | \fBlinsert \fIlist index element \fR?\fIelement element ...\fR? |
---|
| 19 | .BE |
---|
| 20 | |
---|
| 21 | .SH DESCRIPTION |
---|
| 22 | .PP |
---|
| 23 | This command produces a new list from \fIlist\fR by inserting all of the |
---|
| 24 | \fIelement\fR arguments just before the \fIindex\fR'th element of |
---|
| 25 | \fIlist\fR. Each \fIelement\fR argument will become a separate element of |
---|
| 26 | the new list. If \fIindex\fR is less than or equal to zero, then the new |
---|
| 27 | elements are inserted at the beginning of the list. |
---|
| 28 | .VS 8.5 |
---|
| 29 | The interpretation of the \fIindex\fR value is the same as |
---|
| 30 | for the command \fBstring index\fR, supporting simple index |
---|
| 31 | arithmetic and indices relative to the end of the list. |
---|
| 32 | .VE |
---|
| 33 | .SH EXAMPLE |
---|
| 34 | Putting some values into a list, first indexing from the start and |
---|
| 35 | then indexing from the end, and then chaining them together: |
---|
| 36 | .CS |
---|
| 37 | set oldList {the fox jumps over the dog} |
---|
| 38 | set midList [\fBlinsert\fR $oldList 1 quick] |
---|
| 39 | set newList [\fBlinsert\fR $midList end-1 lazy] |
---|
| 40 | # The old lists still exist though... |
---|
| 41 | set newerList [\fBlinsert\fR [\fBlinsert\fR $oldList end-1 quick] 1 lazy] |
---|
| 42 | .CE |
---|
| 43 | |
---|
| 44 | .SH "SEE ALSO" |
---|
| 45 | list(n), lappend(n), lindex(n), llength(n), lsearch(n), |
---|
| 46 | lset(n), lsort(n), lrange(n), lreplace(n), |
---|
| 47 | .VS 8.5 |
---|
| 48 | string(n) |
---|
| 49 | .VE |
---|
| 50 | |
---|
| 51 | .SH KEYWORDS |
---|
| 52 | element, insert, list |
---|