tcl: classic programs — for-each-line, assert, with-temp-var (+3 tests, 228 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 42s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-06 09:34:26 +00:00
parent cffd3bec83
commit 95b22a648d
4 changed files with 58 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
proc for-each-line {var lines body} {
foreach item $lines {
uplevel 1 [list set $var $item]
uplevel 1 $body
}
}
# Usage: accumulate lengths of each "line"
set total 0
for-each-line line {hello world foo} {
incr total [string length $line]
}
set total