推荐的方法来编写多个IFS的条件
如果4个计数器变量中的任何2个非零,我正在尝试提醒用户。 如果有这样的条件,那么在没有很长时间的情况下编写编码的最佳方法是什么?
# Description: report violation if any 2 type of device counts is non-zero (mix of Vt cells)
if { $count_hvt >0 && ($count_lvt >0 || $count_ulvt>0 ||$count_svt >0 ) } {
return 1
} elseif { $count_lvt >0 && ($count_hvt >0 || $count_ulvt>0 ||$count_svt >0 ) } {
return 1
} elseif { $count_svt >0 && ($count_hvt >0 || $count_lvt>0 ||$count_ulvt >0 ) } {
return 1
} elseif { $count_ulvt >0 && ($count_hvt >0 || $count_lvt>0 ||$count_svt >0 ) } {
return 1
} else {
#puts "-0- return 0"
return 0
}
I am trying to do alert the user if any 2 of the 4 counter variables is non-zero.
What is the best way to code this without a long if else condition like this?
# Description: report violation if any 2 type of device counts is non-zero (mix of Vt cells)
if { $count_hvt >0 && ($count_lvt >0 || $count_ulvt>0 ||$count_svt >0 ) } {
return 1
} elseif { $count_lvt >0 && ($count_hvt >0 || $count_ulvt>0 ||$count_svt >0 ) } {
return 1
} elseif { $count_svt >0 && ($count_hvt >0 || $count_lvt>0 ||$count_ulvt >0 ) } {
return 1
} elseif { $count_ulvt >0 && ($count_hvt >0 || $count_lvt>0 ||$count_svt >0 ) } {
return 1
} else {
#puts "-0- return 0"
return 0
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许基本上是这样
,从列表中滤除等于零的元素,并计算剩下多少元素。
Maybe something like
Basically, filter out the elements equal to zero from a list, and count how many remain.