Linux下TCL的基础使用记录二

常用命令记录:

set------最多使用
unset ------删除变量,它后面可以有任意多个参数

set a monday
puts $a
unset a
puts $a

monday
can’t read “a”: no such variable
while executing
“puts $a”
(file “arr.tcl” line 6)

append------把文本加到一个变量的后面

% set txt hello
hello
% append txt "! How are you"
hello! How are you

incr------把一个变量值加上一个整数。incr要求变量原来的值和新加的值都必须是整数

%set b 2
2
%incr b 3
5

运算符和优先级

按优先级从高到低往下排列的。同一格中的运算符优先级相同
在这里插入图片描述
在这里插入图片描述

函数

数学函数并不是命令,只在表达式(expr)中出现才有意义

%set x 2
2
% expr 2* sin($x<3) 
1.68294196962

TCL中支持的数学函数如下
abs( x)------Absolute value of x.
acos( x)------ Arc cosine of x, in the range 0 to p.
asin( x)------ Arc sine of x, in the range -p/2 to p/2.
atan( x)------ Arc tangent of x, in the range -p/2 to p/2.
atan2( x, y)------ Arc tangent of x/ y, in the range -p/2 to p/2.
ceil( x) ------Smallest integer not less than x.
cos( x)------Cosine of x ( x in radians).
cosh( x)------ Hyperbolic cosine of x.
double( i) ------Real value equal to integer i.
exp( x) ------e raised to the power x.
floor( x) ------Largest integer not greater than x.
fmod( x, y) ------Floating-point remainder of x divided by y.
hypot( x, y) ------Square root of ( x 2 + y 2 ).
int( x) ------Integer value produced by truncating x.
log( x)------ Natural logarithm of x.
log10( x) ------Base 10 logarithm of x.
pow( x, y) ------x raised to the power y.
round( x) ------Integer value produced by rounding x.
sin( x) ------Sine of x ( x in radians).
sinh( x) ------Hyperbolic sine of x.
sqrt( x)------ Square root of x.
tan( x) ------Tangent of x ( x in radians).
tanh( x)------ Hyperbolic tangent of x.

加粗样式### 集合(List)

语法: list ? value value…?

% list 1 2 {3 4}
1 2 {3 4}

命令:
concat -------把多个list合成一个list,每个list变成新list的一个元素。
lindex---------返回list的第index个元素
llength--------返回list的元素个数
linsert---------返回一个新串,新串是把所有的value参数值插入list的第index个元素之前得到
lreplace-------返回一个新串,新串是把list的第first到第last个元素用所有的value参数替换得到的。如果没有value参数,就表示删除第first到第last个元素
lrange---------返回list的第first (0-based)到第last 元素组成的串,如果last的值是end。就是从第first个直到串的最后。
lappend-------把每个value的值作为一个元素附加到变量varname后面,并返回变量的新值,如果varname不存在,就生成这个变量。
lsearch
lsort
split
join

流程控制:

if–elseif----
while
for
foreach
switch
break/continue

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

勇敢凡凡

xixixi

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值