guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: loop translations (was: Re: language translator help)


From: David Pirotte
Subject: Re: loop translations (was: Re: language translator help)
Date: Sun, 28 Apr 2002 01:06:52 -0400

I would do this:

1. defining a 'do' whatever module, mine has the following 2 defs;

;; this is my 'do.scm' file, in 'alto' directory accessible
;; which means a subdirectory of the ones listed in GUILE_LOAD_PATH

(define-module (alto do))

(export dotimes
        dolist)

(use-modules (ice-9 syncase))

(define-syntax dolist
  (syntax-rules ()
    ((dolist (?var ?ls) . ?body)
     (for-each (lambda (?var) . ?body) ?ls))
    ((dolist (?var ?ls ?result) . ?body)
     (begin (for-each (lambda (?var) . ?body) ?ls)
            ?result))))

(define-syntax dotimes
  (syntax-rules ()
    ((dotimes (?var ?count . ?result) . ?body)
     (let ((limit ?count))
       (do ((?var 0 (+ ?var 1)))
           ((>= ?var limit) . ?result)
         . ?body)))))

;; end of file

now it is 'very' simple, as simple as:

(use-modules (alto do))

(dotimes (i 3)
  ;; here comes what ever and how many sexp you wanado ...
  (display i) (display "\n")
  )

hope this helps
david




reply via email to

[Prev in Thread] Current Thread [Next in Thread]