3 ms·
Your code sample isn't quite right. [read stdin] returns a string (not a list of strings), which is parsed as a list when you try to loop over it. The parsing
by anon_d 16y ago
Your code sample isn't quite right.
[read stdin] returns a string (not a list of strings), which is parsed as a list when you try to loop over it. The parsing breaks the string into a list of words, so the second loop is redundant. The parsing could fail if the input file isn't valid list syntax (unmatching {}'s). [split _] makes it safe.
foreach word [split [read stdin]] {
if [string match *ing $word] { puts $word }}
I love Tcl too! Tcl is a scripting language for C, Python is less-powerful version of Lisp.
- phsoftnet 16y agoYes you're right hehe. less powerful version of Lisp? that's weird but oh well ..