Posted to tcl by Bombo at Sat May 04 12:52:40 GMT 2024view raw
- #!/usr/bin/env tclsh
- if { $argc == 1 } {
- set num [lindex $argv 0]
- } else {
- puts "nope"
- exit
- }
- proc add_dots {num} {
- set length [string length $num]
- set out ""
- set o 0
- for {set i [expr $length]} {$i > 0} {incr i -1} {
- incr o
- set char [string index $num $i-1]
- if { ![expr $o % 3] && $o != $length } {
- set out ".$char$out"
- } {
- set out "$char$out"
- }
- }
- return "$out"
- }
- set withdots [add_dots $num]
- puts "$withdots"