Debian Codegraph @

doc/lappend.n

raw
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 <[email protected]>. 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 .TH lappend n "" Tcl "Tcl Built-In Commands"
10 .so man.macros
11 .BS
12 '\" Note: do not modify the .SH NAME line immediately below!
13 .SH NAME
14 lappend \- Append list elements onto a variable
15 .SH SYNOPSIS
16 \fBlappend \fIvarName \fR?\fIvalue value value ...\fR?
17 .BE
18 .SH DESCRIPTION
19 .PP
20 This command treats the variable given by \fIvarName\fR as a list
21 and appends each of the \fIvalue\fR arguments to that list as a separate
22 element, with spaces between elements.
23 If \fIvarName\fR does not exist, it is created as a list with elements
24 given by the \fIvalue\fR arguments.
25 \fBLappend\fR is similar to \fBappend\fR except that the \fIvalue\fRs
26 are appended as list elements rather than raw text.
27 This command provides a relatively efficient way to build up
28 large lists. For example,
29 .QW "\fBlappend a $b\fR"
30 is much more efficient than
31 .QW "\fBset a [concat $a [list $b]]\fR"
32 when \fB$a\fR is long.
33 .SH EXAMPLE
34 .PP
35 Using \fBlappend\fR to build up a list of numbers.
36 .PP
37 .CS
38 % set var 1
39 1
40 % \fBlappend\fR var 2
41 1 2
42 % \fBlappend\fR var 3 4 5
43 1 2 3 4 5
44 .CE
45 .SH "SEE ALSO"
46 list(n), lindex(n), linsert(n), llength(n), lset(n),
47 lsort(n), lrange(n)
48 .SH KEYWORDS
49 append, element, list, variable