我正在尝试替换列表中的变量:
% set a 1
1
% set b {1 $a}
1 $a
%
% set a 1
1
% set b [list 1 $a]
1 1
Run Code Online (Sandbox Code Playgroud)
当我使用花括号{}来定义列表时,变量 'a' 不会被替换为它的值,但在使用list它的情况下会替换。
使用定义的列表时如何替换变量的值{}?
我在Expect脚本中编写正则表达式并希望使用([0-9] +)\ r \n作为正则表达式模式.为了防止[...]替代我用弯括号:
expect -re {([0-9]+)\r} {...}
但是{ \ }中的\ r 在括号中没有特殊含义(被视为两个字符).我试试
expect -re {([0-9]+)}\r {...}
但这需要解析错误.我试试
expect -re [concat {([0-9]+)} "\r"] {...}
但是concat在args之间增加了空间.
PS.我知道引用[ ...]引用的另一个解决方案[:
expect -re "(\[0-9]+)\r" {...}
但希望听到{...}引用风格的解决方案......
我想在 TCL 中实现以下 C 代码:
Float power_pitch = 8
float offset = 7.5
float threshold = 100
for(i=power_pitch+offset ; i<= threshold ; i += power_pitch)
Run Code Online (Sandbox Code Playgroud)
我想在TCL中实现上面的forloop。我在 TCL 中尝试了以下代码:
set power_pitch 8
set offset 7.5
set threshold 100
for { set i [expr $power_pitch + $offset] } { $i <= $threshold } { incr i $power_pitch}
Run Code Online (Sandbox Code Playgroud)
但是当我执行上面的代码时,我收到以下错误:
预期的整数,但在执行 incr i $power_pitch 时得到“15.5”
你能帮我在TCL中实现上面的forloop吗?
我有三个清单:
set l1 {1 2 3}
set l2 {'one' 'two' 'three'}
set l3 {'uno' 'dos' 'tres'}
Run Code Online (Sandbox Code Playgroud)
我想建立这个清单:
{{1 'one' 'uno'} {2 'two' 'dos'} {3 'three' 'tres'}}
Run Code Online (Sandbox Code Playgroud)
在python,我会使用类似内置函数的东西zip.我该怎么办tcl?我查看了'concat'的文档,但没有找到先验相关的命令.