common-lisp 有条件地执行LOOP子句
示例
LOOP有自己的IF语句,可以控制子句的执行方式:
(loop repeat 1000
for x = (random 100)
if (evenp x)
collect x into evens
else
collect x into odds
finally (return (values evens odds)))在IF主体中组合多个子句需要特殊的语法:
(loop repeat 1000
for x = (random 100)
if (evenp x)
collect x into evens
and do (format t "~a is even!~%" x)
else
collect x into odds
and count t into n-odds
finally (return (values evens odds n-odds)))
热门推荐
10 幼儿老师过年简短祝福语
11 祝朋友祝福语简短好看
12 简短搞笑的虎年祝福语
13 生物老师英语祝福语简短
14 孩子满月随礼简短祝福语
15 二胎祝福语简短霸气
16 对上司的简短祝福语
17 闺蜜好运祝福语简短
18 送给情侣贺卡祝福语简短