From 72c39ab92583bc878e7282d082a494ae2da115ff Mon Sep 17 00:00:00 2001 From: erana Date: Mon, 23 Jan 2012 15:12:11 +0900 Subject: [PATCH] scratch - char-continuation functions --- scsh/scratch/scratch.scm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scsh/scratch/scratch.scm b/scsh/scratch/scratch.scm index 598f53e..f94c1ed 100644 --- a/scsh/scratch/scratch.scm +++ b/scsh/scratch/scratch.scm @@ -26,7 +26,13 @@ ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ;;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -(define (char-continue lst) + +;; inner syntax +;; test +;; (list-generate-element a b c) generates an element with each call + + +(define (list-generate-element lst) (define (get-char return) (for-each (lambda (element) @@ -40,5 +46,11 @@ (define (gen) (call-with-current-continuation get-char)) gen) + +;; outer syntax ;; test -;; (char-continue l) generates the chars with each call +;; (list-gen a b c) gives an element of '(a b c) each call +(define-syntax list-gen + (syntax-rules () + ((_ a ...) + (list-generate-element (make-list a ...)))))