Cadence Skill 论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4555|回复: 1

[已解决] 请大神们帮忙解释一下红色字体显示的结果是怎么出来的啊,谢谢。

[复制链接]
发表于 2014-3-11 10:54:08 | 显示全部楼层 |阅读模式
procedure( trMakeComplex( @key ( real 0 ) ( imaginary 0 ) )
let( ( result )
result = ncons(nil)
result->real = real
result->imaginary = imaginary
result
) ; let
) ;procedure
complex1 = trMakeComplex( ?real 2 ?imaginary 3 )
=> (nil imaginary 3 real 2)
complex2 = trMakeComplex( ?real 4 ?imaginary 5 )
=> (nil imaginary 5 real 4)
i = trMakeComplex( ?imaginary 1 )
=> (nil imaginary 1 real 0)
procedure( trComplexAddition( cmplx1 cmplx2 )
trMakeComplex(
?real cmplx1->real + cmplx2->real
?imaginary cmplx1->imaginary + cmplx2->imaginary
)
) ; procedure
procedure( trComplexMultiplication( cmplx1 cmplx2 )
trMakeComplex(
?real
cmplx1->real * cmplx2->real -
cmplx1->imaginary * cmplx2->imaginary
?imaginary
cmplx1->imaginary * cmplx2->real +
cmplx1->real * cmplx2->imaginary
)
) ; procedure
trComplexMultiplication( i i ) => (nil imaginary 0 real -1)
In several
发表于 2014-3-11 19:46:01 | 显示全部楼层
result = ncons(nil)相当于创建一个list,该list中包含一个nil的值。
ncons等效于cons( g_element nil )

result->real = real 等于将result的real属性附上real的值
result->imaginary = imaginary等于将result的imaginary属性附上imaginary的值。

所以complex1 = trMakeComplex( ?real 2 ?imaginary 3 )返回的结果为(nil imaginary 3 real 2)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|网站地图|Cadence Skill 论坛 ( 蜀ICP备13024417号 )

GMT+8, 2024-11-23 23:01 , Processed in 0.121520 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表