From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Christopher Howard Newsgroups: gmane.lisp.guile.user Subject: Re: Repeat syntax Date: Sat, 25 Nov 2017 07:48:07 -0900 Message-ID: <1511628487.26826.6.camel@qlfiles.net> References: <1511586326.26826.3.camel@qlfiles.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-iibkZt46ECZoUV7RZ4WA" X-Trace: blaine.gmane.org 1511628539 6597 195.159.176.226 (25 Nov 2017 16:48:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 25 Nov 2017 16:48:59 +0000 (UTC) Cc: Guile User Mailing List To: Matt Wette Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Nov 25 17:48:53 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 1eIddE-0000hV-7n for guile-user@m.gmane.org; Sat, 25 Nov 2017 17:48:44 +0100 Original-Received: from localhost ([::1]:53674 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eIddL-0004Pw-Mr for guile-user@m.gmane.org; Sat, 25 Nov 2017 11:48:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eIdcp-0004P6-Hg for guile-user@gnu.org; Sat, 25 Nov 2017 11:48:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eIdcm-0002oZ-FT for guile-user@gnu.org; Sat, 25 Nov 2017 11:48:19 -0500 Original-Received: from mx.kolabnow.com ([95.128.36.42]:30724) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eIdcm-0002oC-3x for guile-user@gnu.org; Sat, 25 Nov 2017 11:48:16 -0500 Original-Received: from localhost (unknown [127.0.0.1]) by ext-mx-out003.mykolab.com (Postfix) with ESMTP id 3A56A400E6; Sat, 25 Nov 2017 17:48:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= mime-version:content-type:content-type:references:in-reply-to :date:date:from:from:subject:subject:message-id:received :received:received; s=dkim20160331; t=1511628492; x=1511628514; bh=P7VL+b8qopLnBSa4wq2jfKEhjuir9kQfdtjF1Z+bbI8=; b=ByBjqUfkMeQh N8onLYMxPC5JVi7GtESkuoOW607yOh7Us4aILc6kCqA6DsPaHx3HAnbazXJMXa+i lufmx/UQj3AWRK0ET9ZtdZgpVIjWne8eL5V2NHjGH7JZwEq+ArNz9av/oc0Aoodv TJca6lE7O8FH1GH6KT102Tov9j3Vtk2NpDTLo1WSDWX5Q8jMWidFCn4eGzHbjC5P R+wj+gWVpuaCouYtO2InTtXnmbx6Ko1SN8UufN8cljT7Or1DLlkGW0zsGsy7hjHz L1hD6+dA0lA6A+bkQ1y3pafUIvWByCfQ4WcRqY7HGIe93A8jpIS7Ldrb6AAtJi6A QE983qmrr1PaiABd0ssBo+6YzehKnGliX95xYCRZtDOEdF23GshWcHOs7tO/mmX7 gEwCCoqAcn6gYDfswiR4PtwAh2fhOoz9BcnJAusO3ptvIaxtjZzGk65L3ED2xc15 NtXqobUM/ARWOd9bYG0ce/Dvxr+hJHfLxgppjENivv+WXUI9nS+KJDVktNqQJ2dC CJLqOyw9UurVclaSC3hiMIfLXJks11CcftPL5bR0Tm10Gln X-Virus-Scanned: amavisd-new at mykolab.com Original-Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out003.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2dBH_fP8c-os; Sat, 25 Nov 2017 17:48:12 +0100 (CET) Original-Received: from int-mx003.mykolab.com (unknown [10.9.13.3]) by ext-mx-out003.mykolab.com (Postfix) with ESMTPS id 9A3F2400D1; Sat, 25 Nov 2017 17:48:12 +0100 (CET) Original-Received: from ext-subm003.mykolab.com (unknown [10.9.6.3]) by int-mx003.mykolab.com (Postfix) with ESMTPS id 70C56A58; Sat, 25 Nov 2017 17:48:12 +0100 (CET) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 95.128.36.42 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:14292 Archived-At: --=-iibkZt46ECZoUV7RZ4WA Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, 2017-11-25 at 07:06 -0800, Matt Wette wrote: > > On Nov 25, 2017, at 6:47 AM, Matt Wette > > wrote: > >=20 > > you probably want named let > >=20 > > ((_ n exp exp* ...) > > (let loop ((n n)) > > =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 exp* ... > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(loop (1- n))) >=20 > but not a broken one >=20 > ((_ n exp exp* ...) > =C2=A0(let loop ((cnt n)) > =C2=A0=C2=A0=C2=A0(unless (<=3D cnt 0) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0exp exp* ... > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(loop (1- cnt))))) >=20 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=C2=A0times, 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 =C2=A0 (syntax-rules () =C2=A0=C2=A0=C2=A0=C2=A0((_ n exp exp* ...) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(let loop ((cnt n)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(unless (<=3D cnt 0) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0exp exp* ... =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0(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. --=20 https://worldenglishbible.org/ --=-iibkZt46ECZoUV7RZ4WA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEE3cRyrLOhI3rPcNVUee7NbCP9XMUFAloZnscACgkQee7NbCP9 XMXPdggAqwDglbAdvKEsqVT2IZhPMPeXEubL87bfiw/gJ4yGybKRZUlH82+kBVTv 1087CS4sTLtlRbNEqtn7iOhZIY9Wq4jpgf1V6ZSBStnNqqUvdUsFLTbUYY7SM0OH iX22RPbQJYK3IfVCXjc021lmoG3ebLOeoeKHNeSsTUYBjxr/qhLNdOssizY//iZD oF6RBv2sB8paHUzu+q/CVRir2WxuRLFGGr2k8Nije5WQsNrgrY+lv0YY2Y54YD5+ 3cONFDrBhIWGpm+8Evc6K1rwGIJWo5MBMWtfaXxY5weqIcfbGmrVjb9qqnT3+hgm 1Oc8auO3WXO/j423l4cBEaS9JV2BHw== =K3TR -----END PGP SIGNATURE----- --=-iibkZt46ECZoUV7RZ4WA--