From 2b7eadaa80204deef013afcb6e6793b819dbab30 Mon Sep 17 00:00:00 2001 From: Jacob Ritchie Date: Fri, 27 May 2016 11:25:13 +0200 Subject: Edited tcl.html.markdown to fix a few bugs in the code and formatting error. (#1777) --- tcl.html.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tcl.html.markdown') diff --git a/tcl.html.markdown b/tcl.html.markdown index b90bd690..4ff1d3cc 100644 --- a/tcl.html.markdown +++ b/tcl.html.markdown @@ -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 -- cgit v1.2.3