Posted to tcl by Bombo at Sat May 04 12:52:40 GMT 2024view raw

  1. #!/usr/bin/env tclsh
  2.  
  3. if { $argc == 1 } {
  4. set num [lindex $argv 0]
  5. } else {
  6. puts "nope"
  7. exit
  8. }
  9.  
  10. proc add_dots {num} {
  11. set length [string length $num]
  12. set out ""
  13. set o 0
  14.  
  15. for {set i [expr $length]} {$i > 0} {incr i -1} {
  16. incr o
  17. set char [string index $num $i-1]
  18.  
  19. if { ![expr $o % 3] && $o != $length } {
  20. set out ".$char$out"
  21. } {
  22. set out "$char$out"
  23. }
  24. }
  25.  
  26. return "$out"
  27. }
  28.  
  29. set withdots [add_dots $num]
  30. puts "$withdots"
  31.