unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: jerry <jdinardo@nycap.rr.com>
To: guile-user <guile-user@gnu.org>
Subject: Re: guile style
Date: Sat, 19 Jun 2021 22:21:39 -0400	[thread overview]
Message-ID: <89fb08cd-5687-c34b-7c32-686812307c7a@nycap.rr.com> (raw)
In-Reply-To: <c3036ce1-72b1-4159-aff3-5233cee20a13@www.fastmail.com>

On 6/19/21 1:59 PM, Linus Björnstam wrote:

Unlike Donald Knuth, I can't stop myself from premature optimization and
so far, in my short Guile career, I have almost always used my option 3.
I will look into srfi-158 and srfi-171 because they look very interesting.

Based on the responses here, I get the feeling that there is no one 
right way which makes me happy. The reason that I reached out to the 
mailing list is that I recently read that explicit recursion was the 
"goto" of Lisp. Because I like things to be fast/efficient, I always try 
to find a tail call optimized recursion algorithm. I am just looking 
into prompts which apparently will let me break out of folds which was
often an annoyance for me in Haskell. Thanks for all the responses.


> 
> Hi Jerry!
> 
> For this to work guile would need to be either pure or lazy. Lazy, because a value would only be pulled through the chain when needed, which would change the evaluation order in a way that would be compatible with side effects. Pure because without side effects fusing two loops can be done without fear.
> 
> Haskell is of course both. You can get lightweight laziness using srfi-158 - which isn't really loop fusion, but chaining 1000 generator clauses is still O(n).
> 
> What guile does have is an eager construct that does something similar to loop fusion: transducers. Look at srfi-171. One can compose transducers without building want intermediate collections: (list-transduce (compose (tfilter even?) (tmap (lambda (x) (quotient x 2)))) + a-list) will keep all even numbers and divide them by 2, and sum them. No intermediate collections build. They have higher overhead, but are usually faster already at 2 steps.
> 
> Best regards
> Linus Björnstam
> 




      reply	other threads:[~2021-06-20  2:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-19  0:55 guile style jerry
2021-06-19 10:25 ` Tim Van den Langenbergh
     [not found]   ` <CAGua6m1HSYGP6i60Qyj=sVAgeriOzZmb1abCtoxnTQQiOgyY-Q@mail.gmail.com>
2021-06-19 11:24     ` Fwd: " Stefan Israelsson Tampe
2021-06-19 11:31   ` jerry
2021-06-19 11:17 ` Ricardo Wurmus
2021-06-19 11:20 ` Christopher Lam
2021-06-19 12:16   ` jerry
2021-06-19 17:02     ` Zelphir Kaltstahl
2021-06-19 17:59     ` Linus Björnstam
2021-06-20  2:21       ` jerry [this message]

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=89fb08cd-5687-c34b-7c32-686812307c7a@nycap.rr.com \
    --to=jdinardo@nycap.rr.com \
    --cc=guile-user@gnu.org \
    /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).