Posted to tcl by Stu at Sat Oct 10 13:40:44 GMT 2020view raw
- # Remove blank lines and comment lines, add space-backslash to all lines but the last.
- # Useful for making big lists in code without all the unpleasant backslashes.
- #
- proc backslashify {blob} { return [join [lmap l [split $blob \n] { if {[regexp {^[[:space:]]*(#.*)?$} $l]} { continue } else { set l } }] " \\\n"] }
- set l [eval list [backslashify {
- val
- $var
- # comment
- [dict create a b c d]
- ...
- }]