Tcl命令操做實驗-----(11)--- 過程

TCL的過程:spa

Vivado% proc factorial {number} {
if {$number <=  1}  {
   return 1
}
return  [expr $number * [factorial [expr $number - 1]]]
}
Vivado% puts [factorial 3]
6

我發現一個參數好象不 能設爲默認 參考:

Vivado% proc factorial {number {5} } {
if {$number <=  1}  {
   return 1
}
return  [expr $number * [factorial [expr $number - 1]]]
}
Vivado% puts  [factorial ]
wrong # args: should be "factorial number 5"
Vivado% puts  [factorial {3 5}]
wrong # args: should be "factorial number 5"
Vivado% puts  [factorial {3}]
wrong # args: should be "factorial number 5"
相關文章
相關標籤/搜索