Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 拆分字符串重复Tcl_String_Tcl - Fatal编程技术网

String 拆分字符串重复Tcl

String 拆分字符串重复Tcl,string,tcl,String,Tcl,我是Tcl的新学员,我面临着理解整个概念的问题: <name of variable> set [split "[string repeat "-,-," [columns]]-",] set[split”[string repeat-,-,“[columns]]]-,] 列是一个值为6的变量; 如何分割,哪一个是我的整个字符串 谢谢大家 <name of variable> set [split "[string repeat "-,-," [columns]]-"

我是Tcl的新学员,我面临着理解整个概念的问题:

<name of variable> set [split "[string repeat "-,-," [columns]]-",]
set[split”[string repeat-,-,“[columns]]]-,]
列是一个值为6的变量; 如何分割,哪一个是我的整个字符串

谢谢大家

<name of variable> set [split "[string repeat "-,-," [columns]]-",]

证明:

set columns 6
proc columns {} {return $::columns}
set result [split "[string repeat "-,-," [columns]]-" ,]
puts $result
puts [llength $result] ;# should be 13

您可以通过以下方式获得相同的结果:

set result [lrepeat [expr {2 * [columns] + 1}] "-"]


Tcl实际上是一种非常简单的语言。整个语法只有12条规则:

我不确定我是否理解您要问的问题,但是您是否尝试过运行这段代码?您有什么实际的输入数据?你想要什么样的输出?这样看起来很合理,谢谢大家的帮助!
- - - - - - - - - - - - -
13
set result [lrepeat [expr {2 * [columns] + 1}] "-"]