Cadence_Skill_语法详解(中文).docxVIP

  • 239
  • 0
  • 约1.98万字
  • 约 50页
  • 2020-11-01 发布于天津
  • 举报
实用标准文档 实用标准文档 文案大全 文案大全 常量、变量 常量是它的值等于自身的表达式,如 123,” abc ” 变量是保存了其它值的表达式,如 x=3, x即变量。 算术与逻辑操作符 函数名 语法 对应操作符 Data Access arrayref a[i ndex] [] setarray a[i ndex] = expr bitfieldl xbit setqbitfieldl xbit=expr setqbitfield xmsb:lsb=expr quote expr 1 getqq g.s getq g-s - putpropqq g.s=expr, g-s=expr putpropq d~s, d~s =expr ~ Unary prein creme nt ++s ++ posti ncreme nt s++ ++ predecreme nt --s -- postdecreme nt s-- -- min us -n — not !expr ! bnot ~x Binary expt n1 ** n2 ** times n1 * n2 * quotie nt n1 / n2 / plus n1 + n2 + differe nee n1 - n2 - leftshift x1 x2 rightshift x1 x2 lessp n1n2 greaterp n1n2 leqp n1=n2 = geqp n1=n2 = equal g1 == g2 == nequal g1 != g2 != band x1 x2 bnand x1 ~ x2 ? bxor x1 A x2 A bxnor x1 ~a x2 ?A bor x1 | x2 | bnor x1 ~| x2 ?1 and x1 x2 or x1 || x2 II range gi : g2 setq s = expr = 对于既有函数名又有操作符函数,采用函数名调用和采用操作符调用的效果是一样的。 示例 lessp(3 1)=nil 等同于 31=nil 预定义算术函数 语法 结果 通用函数 add1(n) n + 1 sub1(n) n - 1 abs( n) 绝对值 exp( n) 自然对数的n次方 log( n) max( n1 n2 ...) min(n1 n2 ...) mod(x1 x2) 取模运算 round(n) sqrt( n) sxtd(x w) 将x右扩展 W个符号位 zxtd(x w) 和上面的功能相同,速度更快 三角函数 sin(n), cos(n) , tan(n) asin(n) , acos(n) , atan(n) 随机数生成函数 random(x) 产生0?x-1的随机数 TOC \o 1-5 \h \z sran dom(x) 初始化随机数生成函数的 x 位操作 含义 操作符 位与 位或 | 位异或 A 左移位 右移位 取反 ? 真值、假值 ? 真值,除了 nil以为的值都是真值。 ? 假值,nil 条件控制函数 if, whe n, uni ess, cond ? if if函数的语法结构 if( condition 1 then ;当 condition1 为真值时执行代码块 expA expA else if( condition2 then ;当 condition2 为真值时执行代码块 expB expB else expC ) );end if whe n when函数语法结构 whe n( con diti on;当condition 为真值时执行代码块 expA,否则跳过 whe n( con diti on expA );end whe n ? uni ess uni ess语法结构 uniess( condition ;当condition 为假值时执行代码块 expA,否则跳过 expA );end uni ess cond cond语法结构 ;当condition1 为真值时执行代码块 ;当condition1 为真值时执行代码块 expA ;之前的条件都不满足时默认执行 expN (con diti on1 expA...) (con diti on2 expB ...) (con diti on3 expC ...) (t expN ) );end cond [注]:”;表示注释 循环控制函数 while , for , foreach ? while while语法结构 while( condition is true ;当condition 为真值时反复执行代码块 expA,否则 结束循环 expA ) ? for for语法结构 fo

文档评论(0)

1亿VIP精品文档

相关文档