この機構は豊富な操作手続を提供しているので、リストジェネレータとい うだけではなく、ジェネリックなループ構文(Common Lisp の loop マ クロ並みに強力/邪悪だという人もいます)を提供しています。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use srfi-42) | |
(do-ec (: n 10)(display n)) | |
; -> 0123456789#<undef> | |
(do-ec (:range n 1 10)(display n)) | |
; -> 123456789#<undef> | |
(let ((acc 'pizza)) | |
(do-ec (: n 5)(set! acc (cons acc '()))) | |
acc) | |
; -> (((((pizza))))) | |
(list-ec (: x 2 5) (: y 1 x) (list x y)) | |
; -> ((2 1) (3 1) (3 2) (4 1) (4 2) (4 3)) |
0 件のコメント:
コメントを投稿