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: rm
Subject: Re: loop translations (was: Re: language translator help)
Date: Sun, 28 Apr 2002 11:52:43 +0200
User-agent: Mutt/1.3.24i

On Sun, Apr 28, 2002 at 01:06:52AM -0400, David Pirotte wrote:
If you are looking for common lisp like loop constructs,
Rick Taube has written a set of macros. I've wrapped them as a guile
module, send me mail if you need them (orig. code is GPL).

Ralf Mattes

> 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
> 
> 
> _______________________________________________
> Guile-user mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/guile-user



reply via email to

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