unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>
To: tomas@tuxteam.de
Cc: guile-user@gnu.org
Subject: Re: Writing a procedure in different style
Date: Sun, 20 Dec 2020 18:57:34 +0100	[thread overview]
Message-ID: <93cfbdc6-a013-d6c8-15a7-b2d2feb2455a@posteo.de> (raw)
In-Reply-To: <20201213154300.GC6620@tuxteam.de>

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.

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 the
>> 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? ...), not
>> the thing, that you give as argument to a recursive call or as a return
>> 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 usual
>> (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

-- 
repositories: https://notabug.org/ZelphirKaltstahl





  reply	other threads:[~2020-12-20 17:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-12 12:22 Writing a procedure in different style Zelphir Kaltstahl
2020-12-13  7:06 ` Taylan Kammer
2020-12-13 11:51   ` Taylan Kammer
2020-12-13 12:29     ` Zelphir Kaltstahl
2020-12-13 14:24       ` tomas
2020-12-13 15:01         ` Zelphir Kaltstahl
2020-12-13 15:43           ` tomas
2020-12-20 17:57             ` Zelphir Kaltstahl [this message]
2020-12-21 12:31               ` tomas
2020-12-21 21:29                 ` Zelphir Kaltstahl

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=93cfbdc6-a013-d6c8-15a7-b2d2feb2455a@posteo.de \
    --to=zelphirkaltstahl@posteo.de \
    --cc=guile-user@gnu.org \
    --cc=tomas@tuxteam.de \
    /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).