Posted to tcl by florentis at Wed Oct 14 13:44:59 GMT 2026view raw

  1. # TIP 764 example
  2. # Strings can keep their atomicity :
  3.  
  4. set A {Hello World}
  5. set B {What's up doc ?}
  6.  
  7. set {list.string}L $A $B
  8.  
  9. foreach e $L {
  10. foreach f $e {
  11. puts "[type get $f] : $f"
  12. }
  13. }
  14. # string : hello World
  15. # string : How are you ?
  16.  
  17. # Usual Tcl
  18. # strings are parsed as sublists
  19. set G [list $A $B]
  20. foreach e $G {
  21. foreach f $e {
  22. puts "[type get $f] : $f"
  23. }
  24. }
  25. # : hello
  26. # : World
  27. # : How
  28. # : are
  29. # : you
  30. # : ?

Add a comment

Please note that this site uses the meta tags nofollow,noindex for all pages that contain comments.
Items are closed for new comments after 1 week