RosettaCodeData/Task/Increment-a-numerical-string/Tcl/increment-a-numerical-string-1.tcl

13 lines
281 B
Tcl
Raw Permalink Normal View History

2025-06-11 20:16:52 -04:00
# n is string
set n "1234"
2026-04-30 12:34:36 -04:00
# increments the integer rep to 1235, updates string rep to "1235"
incr n
2025-06-11 20:16:52 -04:00
# integer rep added to n
# o is calculated integer
2026-04-30 12:34:36 -04:00
set val [expr {$n + 1}]
2025-06-11 20:16:52 -04:00
# n is string,
# o used as string adds string representation to o
puts stdout "$n incrememented is $o"