unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Repeat syntax
@ 2017-11-25  5:05 Christopher Howard
  2017-11-25  8:39 ` Alex Vong
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Christopher Howard @ 2017-11-25  5:05 UTC (permalink / raw)
  To: Guile User Mailing List

[-- Attachment #1: Type: text/plain, Size: 873 bytes --]

Hi list, I want to have a function

  (repeat n exp exp* ...)

That calls the expressions n times for side effect, like for-each, but
without the bother of dealing with a list. It seems like somebody else
must have thought of this before, but I couldn't find the equivalent
procedure. After reading 6.10.2 I came up with this

(define-syntax repeat
  (syntax-rules (repeat)
    ((_ n exp exp* ...)
     '(unless (<= n 0)
       exp
       exp*
       ...
       (repeat (- n 1) exp exp* ...)))))

Which doesn't work I think because repeat gets expanded infinitely many
times. I was pondering other ways to do this, but they all seem to end
in either infinite expansion, or an important variable getting
overshadowed. So, could somebody point me in the right direction?

-- 
https://emailselfdefense.fsf.org/en/

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-12-30 13:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-25  5:05 Repeat syntax Christopher Howard
2017-11-25  8:39 ` Alex Vong
2017-11-25 14:47 ` Matt Wette
2017-11-25 15:06   ` Matt Wette
2017-11-25 16:48     ` Christopher Howard
2017-11-25 15:21 ` Chris Vine
2017-11-25 15:34   ` Chris Vine
2017-12-30 13:18 ` Taylan Ulrich Bayırlı/Kammer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).