Cadence Skill 论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4570|回复: 3

[求助] Skill 语法解释

[复制链接]
发表于 2015-4-7 13:55:26 | 显示全部楼层 |阅读模式
procedure( trListOfSquares( aList )
       let( ( filterdList ) ;定义一个局部变量
             filterList = setof( element aList oddp( element ) ); 得到列表中的奇数
             foreach( mapcar element filterdList ;觉得这行符合foreach的语法吗?
                          element * element          ;mapcar为什么写在这个位置并且mapcar的一个参数不是
            );end of foreach                            ;u_fun吗。
       );end of let
希望得到Skill能人的解答。谢谢
);end of trListOfSquares
 楼主| 发表于 2015-4-7 13:57:24 | 显示全部楼层
函数的功能是,对一个列表中的奇数求平方
如: trListOfSquares( '(1 2 3 4 5 6 7) ) ===>(1 9 25 49 )
发表于 2015-4-7 22:18:23 | 显示全部楼层
你参考下foreach就知道了。

Advanced Usage

The foreach function typically expands to call mapc; however, you can also request that a specific mapping function be applied by giving the name of the mapping function as the first argument to foreach. Thus, foreach can be used as an extremely powerful tool to construct new lists.

Note:  Mapping functions are not accepted when this form is applied to association tables.

foreach( mapcar x '(1 2 3) (x >1))=> (nil t t)
foreach( mapcan x '(1 2 3) if((x > 1) ncons(x))) => (2 3)
foreach( maplist x '(1 2 3) length(x)) => (3 2 1)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-5-1 00:35 , Processed in 0.135990 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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