From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: Re: Writing a procedure in different style Date: Sun, 20 Dec 2020 18:57:34 +0100 Message-ID: <93cfbdc6-a013-d6c8-15a7-b2d2feb2455a@posteo.de> References: <3760549b-b32f-fafc-1291-8e3eda7b3753@posteo.de> <2d6f348c-1e43-a5c4-1998-baa04b91bf8c@gmail.com> <1385bd6a-c14e-76f1-6dfe-4cf50d192375@gmail.com> <33683c10-5e29-8e4a-03a4-64852fbcf474@posteo.de> <20201213142412.GB6620@tuxteam.de> <66a4948b-6c35-d9df-daa0-865956f52821@posteo.de> <20201213154300.GC6620@tuxteam.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5524"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Icedove/68.10.0 Cc: guile-user@gnu.org To: tomas@tuxteam.de Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Dec 20 18:57:54 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kr2xu-0001HV-94 for guile-user@m.gmane-mx.org; Sun, 20 Dec 2020 18:57:54 +0100 Original-Received: from localhost ([::1]:39768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kr2xt-0005W3-B6 for guile-user@m.gmane-mx.org; Sun, 20 Dec 2020 12:57:53 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kr2xi-0005Vu-Ks for guile-user@gnu.org; Sun, 20 Dec 2020 12:57:42 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:55566) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kr2xf-0004El-1f for guile-user@gnu.org; Sun, 20 Dec 2020 12:57:42 -0500 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id D742C16006E for ; Sun, 20 Dec 2020 18:57:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1608487056; bh=DmVa9bF6Hz8zGjofl+00QY8WS1WWh+fQ5pZcSDLDuHM=; h=Subject:To:Cc:From:Date:From; b=Txf29GaxpN8hBID1vIYm4quQ6oeh8V5b6sJDRcm1MsTa76OM4jmCRzIVSLg8P8ty1 gVwFAao5UZ9+uIDvar1XWVyaaOOWd2gYT31zGoCwYrw2jiKkP6BvbOBqaf8cVRdafE w8rcqXQDyHt9c0HY6jjvyhTHNxZHVf+9ed282+94q5FmMYpcsOxXpQcOwT3h5r09kZ 92Hq2/KXBltvfXiHyGlb6wV+RHG0Cw6wM2uh3fsihWPDa7cJuFk05vIdvhoPK1b9hn VZsU/ojgCMyFbakFP43lfyj4H0CaF/Kp28rv4Rl/EjBpFQxaqydPdjwtoziFBwWlMU SV/jxHxMoFR7Q== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4CzVgM1qwVz6tmH; Sun, 20 Dec 2020 18:57:34 +0100 (CET) In-Reply-To: <20201213154300.GC6620@tuxteam.de> Content-Language: en-US Received-SPF: pass client-ip=185.67.36.65; envelope-from=zelphirkaltstahl@posteo.de; helo=mout01.posteo.de X-Spam_score_int: -76 X-Spam_score: -7.7 X-Spam_bar: ------- X-Spam_report: (-7.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-3.299, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17094 Archived-At: Hello Tomas! I think you are right about it only being down one stack frame down. The checks are performed on what contains the next thing which is recurred on= =2E For a moment I thought "But isn't the null? check done twice in the first cond part?" But then I realized, that the rest is split up into car and cdr before recurring on it and that the first check if for the whole of rest, while in the next iteration, the check would only be for the car of rest. So no duplicated work. On 13.12.20 16:43, tomas@tuxteam.de wrote: > On Sun, Dec 13, 2020 at 04:01:24PM +0100, Zelphir Kaltstahl wrote: >> Hi Tomas! >> >> In some way what you write makes sense. Let me state here, that I did >> read that book and worked through it for a year though, even through t= he >> complicated parts like the y-combinator and some chapters I must have >> read like 4 or 5 times and discovered new aspects on each try. > That's it -- I'm through some n-th iteration and still go "oh!" from > time to time :-D > >> What is typically the case in the book is a different situation though= , >> than what was in Taylan's procedure. Usually it is the list you are >> working on in that iteration, which you check for being (null? ...), n= ot >> the thing, that you give as argument to a recursive call or as a retur= n >> value, which you add in some way to the result. Usually the questions >> from the quote are asked once the argument is received in the next >> iteration. That I definitely usually do, but in Taylan's answer there = is >> an (if (null? ...) ...) for the `rest`, inside the case, where the usu= al >> (null? ...) check is already done on the subtree, which we recur on. > I have the hunch that this is only shifting things one level > up or down the stack, but basically, it's the same principle > at work. I'd have to fiddle for a while with that to see whether > I'm totally off, though. > > Anyway, a reminder for me to do the n+1st iteration: "Do It, Do > It Again, and Again, and Again, ..." :-) > > Thanks for that! > > Cheers > - t Regards, Zelphir --=20 repositories: https://notabug.org/ZelphirKaltstahl