mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Edited tcl.html.markdown to fix a few bugs in the code and formatting error. (#1777)
This commit is contained in:
parent
cdc8ff6e6c
commit
2b7eadaa80
@ -105,12 +105,14 @@ set greeting $greeting1$greeting2[set greeting3]
|
||||
# Command substitution should really be called script substitution, because an
|
||||
# entire script, not just a command, can be placed between the brackets. The
|
||||
# "incr" command increments the value of a variable and returns its value.
|
||||
|
||||
set i 0
|
||||
set greeting $greeting[
|
||||
incr i
|
||||
incr i
|
||||
incr i
|
||||
]
|
||||
|
||||
# i is now 3
|
||||
|
||||
# backslash suppresses the special meaning of characters
|
||||
set amount \$16.42
|
||||
@ -149,9 +151,6 @@ set greeting "Hello, [set {first name}]"
|
||||
|
||||
# To promote the words within a word to individual words of the current
|
||||
# command, use the expansion operator, "{*}".
|
||||
```
|
||||
|
||||
```tcl
|
||||
set {*}{name Neo}
|
||||
|
||||
# is equivalent to
|
||||
@ -261,10 +260,11 @@ proc greet greeting\ name return\ \"Hello,\ \$name!
|
||||
# When the last parameter is the literal value, "args", it collects all extra
|
||||
# arguments when the command is invoked
|
||||
proc fold {cmd args} {
|
||||
set res 0
|
||||
set res 1
|
||||
foreach arg $args {
|
||||
set res [$cmd $res $arg]
|
||||
}
|
||||
return res
|
||||
}
|
||||
fold ::tcl::mathop::* 5 3 3 ;# -> 45
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user