|
From: yahalom on 4 Jul 2008 06:11 I was playing with the new "in" and "ni" new expression operators and found that I cannot do: if {$test in [list 3 4 5] || $test ni [list 5 6 7]} { puts "great!" } Are the new expression operators"ni" and "in" limited to one operator? why? I checked the doc http://www.tcl.tk/man/tcl8.5/TclCmd/if.htm and did not see any mention of the new expression operators. where are they documented?
From: schlenk on 4 Jul 2008 06:27 On Jul 4, 12:11 pm, yahalom <yahal...(a)gmail.com> wrote: > I was playing with the new "in" and "ni" new expression operators and > found that I cannot do: > > if {$test in [list 3 4 5] || $test ni [list 5 6 7]} { > puts "great!" > > } > > Are the new expression operators"ni" and "in" limited to one operator? > why? > > I checked the dochttp://www.tcl.tk/man/tcl8.5/TclCmd/if.htmand did > not see any mention of the new expression operators. where are they > documented? AS Tcl 8.5.2 (bin) 4 % set test 3 3 (bin) 5 % if {$test in [list 4 5 6] || $test ni [list 7 8 9]} { > puts "Great" > } Great why do you assume it does not work? The operators are documented on the expr manpages. Michael
From: Glenn Jackman on 4 Jul 2008 09:33 At 2008-07-04 06:11AM, "yahalom" wrote: > I was playing with the new "in" and "ni" new expression operators and > found that I cannot do: > > if {$test in [list 3 4 5] || $test ni [list 5 6 7]} { > puts "great!" > } What about this can't you do? What do you see and how does that differ from your expectations? % for {set test 2} {$test < 9} {incr test} { puts $test if {$test in [list 3 4 5] || $test ni [list 5 6 7]} {puts Great} {puts Terrible} } 2 Great 3 Great 4 Great 5 Great 6 Terrible 7 Terrible 8 Great > I checked the doc http://www.tcl.tk/man/tcl8.5/TclCmd/if.htm and did > not see any mention of the new expression operators. where are they > documented? Some control commands ([if], [while], [for] come to mind) send their (often first) argument to [expr]. You would have read this in the if man page: SYNOPSIS if expr1 ?then? body1 elseif expr2 ?then? body2 elseif ... ?else? ?bodyN? DESCRIPTION The if command evaluates expr1 as an expression (in the same way that expr[linked to expr man page] evaluates its argument). -- Glenn Jackman Write a wise saying and your name will live forever. -- Anonymous
From: Glenn Jackman on 4 Jul 2008 09:35 At 2008-07-04 06:11AM, "yahalom" wrote: > I was playing with the new "in" and "ni" new expression operators and > found that I cannot do: > > if {$test in [list 3 4 5] || $test ni [list 5 6 7]} { > puts "great!" > } What about this can't you do? What do you see and how does that differ from your expectations? % for {set test 2} {$test < 9} {incr test} { puts $test if {$test in [list 3 4 5] || $test ni [list 5 6 7]} { puts Great } else { puts Terrible } } 2 Great 3 Great 4 Great 5 Great 6 Terrible 7 Terrible 8 Great > I checked the doc http://www.tcl.tk/man/tcl8.5/TclCmd/if.htm and did > not see any mention of the new expression operators. where are they > documented? Some control commands ([if], [while], [for] come to mind) send their (often first) argument to [expr]. You would have read this in the if man page: SYNOPSIS if expr1 ?then? body1 elseif expr2 ?then? body2 elseif ... ?else? ?bodyN? DESCRIPTION The if command evaluates expr1 as an expression (in the same way that expr[linked to expr man page] evaluates its argument). -- Glenn Jackman Write a wise saying and your name will live forever. -- Anonymous
|
Pages: 1 Prev: execution time paradox Next: freewrap with blt2.4 demo program: |