From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: jerry Newsgroups: gmane.lisp.guile.user Subject: Re: guile style Date: Sat, 19 Jun 2021 22:21:39 -0400 Message-ID: <89fb08cd-5687-c34b-7c32-686812307c7a@nycap.rr.com> References: <7aeef132-6bd7-c178-5786-c0a3d6b3edc8@nycap.rr.com> <1e959322-f5f8-9bc3-ae08-a30165f9f409@nycap.rr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23293"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 To: guile-user Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Sun Jun 20 04:22:00 2021 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 1lun60-0005vP-Ar for guile-user@m.gmane-mx.org; Sun, 20 Jun 2021 04:22:00 +0200 Original-Received: from localhost ([::1]:35680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lun5z-0004dC-1f for guile-user@m.gmane-mx.org; Sat, 19 Jun 2021 22:21:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lun5o-0004d2-Ly for guile-user@gnu.org; Sat, 19 Jun 2021 22:21:48 -0400 Original-Received: from impout009aa.msg.chrl.nc.charter.net ([47.43.20.33]:45562 helo=impout009.msg.chrl.nc.charter.net) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lun5n-0004ke-2M for guile-user@gnu.org; Sat, 19 Jun 2021 22:21:48 -0400 Original-Received: from [192.168.1.8] ([67.241.26.17]) by cmsmtp with ESMTPA id un5flxjGsoOgEun5kluVmw; Sun, 20 Jun 2021 02:21:44 +0000 Authentication-Results: nycap.rr.com; none X-Authority-Analysis: v=2.4 cv=RYtVt3hv c=1 sm=1 tr=0 ts=60cea638 a=6kFUCgT7isY2CrseCyFLdg==:117 a=6kFUCgT7isY2CrseCyFLdg==:17 a=IkcTkHD0fZMA:10 a=5bbVNav7R1hGFlhs4DEA:9 a=QEXdDO2ut3YA:10 In-Reply-To: Content-Language: en-US X-CMAE-Envelope: MS4xfPeuCwOmMU5PGjTTdxUwu1Dd4UtQNSkFV70FFtJ7R9tUBkh9/+ViOcSyn0bxT56Sg8gEI1uEe65FUVefgznr2gZMVZFANgbF6Etb9MlPIW9RwGxiUzy/ ynEiZKifkv7XELp3gL6jNPCM4+lBhrrek/e7Zd4asj/9k1QhVaMGDERnNaVgpa3Nq547Wm2K9QKICw== Received-SPF: softfail client-ip=47.43.20.33; envelope-from=jdinardo@nycap.rr.com; helo=impout009.msg.chrl.nc.charter.net X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.202, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no 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:17615 Archived-At: 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 >