From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alex Vong Newsgroups: gmane.lisp.guile.user Subject: Re: Repeat syntax Date: Sat, 25 Nov 2017 16:39:13 +0800 Message-ID: <87y3mupxam.fsf@gmail.com> References: <1511586326.26826.3.camel@qlfiles.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1511599208 14918 195.159.176.226 (25 Nov 2017 08:40:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 25 Nov 2017 08:40:08 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cc: Guile User Mailing List To: Christopher Howard Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Nov 25 09:40:02 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eIW0C-0002iP-FQ for guile-user@m.gmane.org; Sat, 25 Nov 2017 09:39:56 +0100 Original-Received: from localhost ([::1]:52400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eIW0F-00037m-04 for guile-user@m.gmane.org; Sat, 25 Nov 2017 03:39:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eIVzo-00032E-07 for guile-user@gnu.org; Sat, 25 Nov 2017 03:39:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eIVzk-0001tQ-Ub for guile-user@gnu.org; Sat, 25 Nov 2017 03:39:32 -0500 Original-Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:40821) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eIVzk-0001sl-O1 for guile-user@gnu.org; Sat, 25 Nov 2017 03:39:28 -0500 Original-Received: by mail-pl0-x243.google.com with SMTP id 62so5626039plc.7 for ; Sat, 25 Nov 2017 00:39:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version; bh=dhYO78HFA31arLxS6+30YdWfaNUtaif14li5OZr4Y/0=; b=T1HRAHYxojK39F22n8xi5lefnf2WVX2xcsczFqZ5TxkiN6KoxkhwFFmfB8reZ1/u1X TC8saKqfA7PahuJwUvOM75qX0uJWOVomJNCAkWYNeEZZz6L7myL21ep6TDXH5nH0D5By aRh3XacByHgO5FlhVqL6H+f8QT4ReNhv8F0Vc8zzM39Qferx4qYEmr4irI+a90Yx4nMu vFJjv17hl3uXwtbfHI9pkUoItYn0KM7H16T0U9DQ4lEhXL3Iq3Yoj38pL1czhuTHkpTR lZylBgMS3J8rBeDZ0z4VcyUG8rilpqRdRV5f6KgEnHUu3TZX9uUIxDCTKORj9CuwaNZm rJ8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version; bh=dhYO78HFA31arLxS6+30YdWfaNUtaif14li5OZr4Y/0=; b=OHv0TUgv4q1kzEwRnNVJclDu86iuNIE7652npPJ2aY3dgrqgVIPEQH4OAy0cJkDebN fn9bpZPX3QvUyCi126JCUQzKou7Yq2bJuWwEOfWj8Ok7CO42FNU67m+lIwAzlICyEL0+ 1WY8mWwf6/l8R9HO14rPQgweXMd7UktEZ34N5ueV7dJf67oSd9VlFTvD1xrflGV6ab2p oVZR5xG+pxcF870jO5JpDAnAQKdrvFqpY/nJX6gCu5gQkTuNThaYz7p9FyqewLiMQBj+ KcWJL3DdlG+1jE1J+pIRwCIL9lDoY1v2Ifkm1LFCV3XRv7THXJgtwhtwUTZDCiv3WCqj nbBQ== X-Gm-Message-State: AJaThX56lvXVqYaS3Efc6a3lR8QtjQ18QVcV6FJzgCHNiAzGrcdCk3pP 09xKe396+EgLyB/IP+i9FGY= X-Google-Smtp-Source: AGs4zMY6e2KjV6lNvzKcpI/uv9IH76an0x7Zy/tuOjFUJr2xAhERjRL3nK5X+hoQgrituAfUeoI89g== X-Received: by 10.84.235.201 with SMTP id m9mr18648287plt.30.1511599166301; Sat, 25 Nov 2017 00:39:26 -0800 (PST) Original-Received: from debian (n058152177150.netvigator.com. [58.152.177.150]) by smtp.gmail.com with ESMTPSA id g5sm33855693pgq.94.2017.11.25.00.39.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 Nov 2017 00:39:25 -0800 (PST) In-Reply-To: <1511586326.26826.3.camel@qlfiles.net> (Christopher Howard's message of "Fri, 24 Nov 2017 20:05:26 -0900") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14287 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Christopher Howard writes: > 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 > =C2=A0 (syntax-rules (repeat) > =C2=A0=C2=A0=C2=A0=C2=A0((_ n exp exp* ...) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0'(unless (<=3D n 0) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0exp > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0exp* > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0... > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(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=C2=A0either infinite expansion, or an important variable getting > overshadowed. So, could somebody point me in the right direction? Do you want to evaluate the expressions during macro-expand-time or run-time? --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEdZDkzSn0Cycogr9IxYq4eRf1Ea4FAloZLDEACgkQxYq4eRf1 Ea5Ohg/6AqPBGkcOhq7kb3mw52dvkZxsY1+HuyqpGLTJve/NV337otKw7TcM/x1+ Hy2JoglSEoLfeI+pVFnl9vWG5ZLplZSL/h+fN9I5SUPKaOv9+JzEPxxisXdtXusm e45X/4uZ1Gkh943PCfHreFawcKw2fwNxFezjPN0JBN6fpUwuzwPVCIX4pd0bHyeb v5p7NH1CCZbKinTE50nxXdefb2KD1DCJc4eJKnfGJSqDHeuDtPlFdc9ydn/kLHVg QHi/8ixlLqpL88UXau5HuvmUKF+Ey5koOXvXqwFFVK/cSxZi1DzDIO8KWUCg8xGL hCW0N33P/WIAbjmQthjxZ0ZCSRtz6IcZIjCDTN1yWDOiem1n1IKpP2mF9cvIEcf9 pHibDldl6rC4OtJHynUjOC27Co9VBU13TPUjN8yv0K9EKv/kU+M7lhVTwNR/fdL7 Jy71WAtt/AujTVjrg5j2UPkOwHbBvRIWS4MUIndDBlG4BK6Bi8xIpnt0FqYE4Mdr haP/ayPiM1Dkl8iCgHfdzKacIJ3MbEtYZ8VMZ8witoYPrM+z3OwbHHD4tpXhFYBB 3SS9FT35X5gnhr98nV+QFxSUxrI0Pg+gwO7JUKpxl/r93Sx8fXWQanqiDsCmtyyP GuOh9l4NSXXFGBszGd3DwfoDxOMuN7sWWxrRTfc8goGZRmoV1mM= =PHMc -----END PGP SIGNATURE----- --=-=-=--