(loop for i in '(one two three four five six) do (print i)) (loop for i in '(one two three four five six) by #'cddr do (print i)) ;prints ONE THREE FIVE (loop for i on '(a b c d e f g) do (print (length i))) ;prints 7 6 5 4 3 2 1 (loop for i on '(a b c d e f g) by #'cddr do (print (length i))) ;prints 7 5 3 1 (loop for i on '(a b c) do (print i)) ;prints (a b c) (b c) (c) (loop for i across #(1 2 3 4 5 6) do (print i)) ; prints 1 2 3 4 5 6 (loop for i across "foo" do (print i)) ; prints #\f #\o #\o (loop for element across "foo" for i from 0 do (format t "~a ~a~%" i element)) ; prints 0 f\n1 o\n1 o
这是关键字的摘要
关键词 | 序列类型 | 变量类型 |
---|---|---|
在 | 清单 | 列表元素 |
上 | 清单 | 清单中的一些cdr |
跨越 | 向量 | 向量元素 |