Code · 1 file
Sample Tcl File
A Tcl script using lists, procs and format. Every language sample implements the same small program so you can compare them side by side.
Tcl · 414 B
Sample Tcl file
An idiomatic Tcl example — the same customer program (or, for hardware languages, a small counter design) we offer in every language.
CC0 · free for any use · Verified by an independent tool · Report a problem
# Sample Tcl script — samplefiles.com
set customers {
{1 Ada 12500.00}
{2 Grace 830.50}
{3 Linus 10000.00}
}
proc isVip {balance} {
expr {$balance >= 10000}
}
set total 0.0
foreach c $customers {
lassign $c id name balance
puts [format "%-6s %10.2f %s" $name $balance [expr {[isVip $balance] ? "VIP" : ""}]]
set total [expr {$total + $balance}]
}
puts [format "Total: %.2f" $total]File details
Download from the command line
curl -L -o sample.tcl https://files.samplefiles.com/code/tcl/sample.tclwget https://files.samplefiles.com/code/tcl/sample.tclhttps://files.samplefiles.com/code/tcl/sample.tclprintf '%s %s\n' 76174636206503373b544f10b19228e8cdbdd656c04d67e7831d191638aba64d sample.tcl | shasum -a 256 -cOr check the download in your browser with the checksum calculator.