From: Christopher Howard <christopher.howard@qlfiles.net>
To: Matt Wette <matt.wette@gmail.com>
Cc: Guile User Mailing List <guile-user@gnu.org>
Subject: Re: Repeat syntax
Date: Sat, 25 Nov 2017 07:48:07 -0900 [thread overview]
Message-ID: <1511628487.26826.6.camel@qlfiles.net> (raw)
In-Reply-To: <FDF2ECED-74CF-4881-8705-933A980C5270@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1280 bytes --]
On Sat, 2017-11-25 at 07:06 -0800, Matt Wette wrote:
> > On Nov 25, 2017, at 6:47 AM, Matt Wette <matt.wette@gmail.com>
> > wrote:
> >
> > you probably want named let
> >
> > ((_ n exp exp* ...)
> > (let loop ((n n))
> > (unless (<= n 0)
> > exp exp* ...
> > (loop (1- n)))
>
> but not a broken one
>
> ((_ n exp exp* ...)
> (let loop ((cnt n))
> (unless (<= cnt 0)
> exp exp* ...
> (loop (1- cnt)))))
>
I want both the looping and the expression evaluation to be happening
at run time. The target is to repeat the side effects of the
expressions n times, and the return values are irrelevant.
I think this last submission from Matt does exactly what I want, the
full version being
(define-syntax repeat
(syntax-rules ()
((_ n exp exp* ...)
(let loop ((cnt n))
(unless (<= cnt 0)
exp exp* ...
(loop (1- cnt)))))))
scheme@(guile-user)> (repeat 10 (display "la\n"))
la
la
la
la
la
la
la
la
la
la
The part that confuses me a little is why
(repeat 10 (display cnt))
doesn't break it. Must be that magical hygiene mentioned in the info page.
--
https://worldenglishbible.org/
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2017-11-25 16:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2017-11-25 15:21 ` Chris Vine
2017-11-25 15:34 ` Chris Vine
2017-12-30 13:18 ` Taylan Ulrich Bayırlı/Kammer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1511628487.26826.6.camel@qlfiles.net \
--to=christopher.howard@qlfiles.net \
--cc=guile-user@gnu.org \
--cc=matt.wette@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).