Skill 语法解释
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 函数的功能是,对一个列表中的奇数求平方
如: trListOfSquares( '(1 2 3 4 5 6 7) ) ===>(1 9 25 49 )
你参考下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) 谢谢,:lol:lol
页:
[1]