From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.user Subject: why I love scheme Date: Wed, 15 Dec 2021 00:44:34 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4567"; mail-complaints-to="usenet@ciao.gmane.io" To: Guile User Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Dec 15 00:45: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 1mxHTg-0000u8-3P for guile-user@m.gmane-mx.org; Wed, 15 Dec 2021 00:45:00 +0100 Original-Received: from localhost ([::1]:49550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxHTe-0004hk-LX for guile-user@m.gmane-mx.org; Tue, 14 Dec 2021 18:44:58 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxHTV-0004ha-Pr for guile-user@gnu.org; Tue, 14 Dec 2021 18:44:49 -0500 Original-Received: from [2a00:1450:4864:20::42c] (port=45012 helo=mail-wr1-x42c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxHTT-0002Sp-L3 for guile-user@gnu.org; Tue, 14 Dec 2021 18:44:49 -0500 Original-Received: by mail-wr1-x42c.google.com with SMTP id t18so35066764wrg.11 for ; Tue, 14 Dec 2021 15:44:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=dADxKvLmPcpBuHVQYpGzeK/LwghiMSSKhLSPDKTP10U=; b=pNNGbwoxj0OIzF47YlN0NeqwtkEHizBzjzMy6b8Vb090l2WAk0QuX69hiHgcgr7n15 dfAzDMSXPOphV1YSssMzJ2PzBTz/CPD1XHOkUmgx8ETa4Qu+3NdH+2fPbUS5iDFzc/N7 LxyghDdsP7XWBGwIrs2hi0I8tqCH/yqtdxOTKZbXpoNGb8Tmpzr830o0PeldJpimaRBV FaE6oBgvRUJowYn+EkZlMbJO62Sqks5VR57HMA1gfTGGDQSH3D0gh5ObevNw/uTtm6tq FW/VyYzoAYfWZWFSgewEmOkfuURO6h1gP8+0b2ZmgLb7X0pXYDUyyqxcGH1xLUzo6BN5 oKsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=dADxKvLmPcpBuHVQYpGzeK/LwghiMSSKhLSPDKTP10U=; b=ikN4l5j8gUBbWX78BJADrQUOSzJF2nDE1Xsq2WQcNIfqSN2JjSoKkliFPajqx/LG9r EH1f4TEiLFVURzVsKTrnLTD9sKisBrueppIh9k6dkYr23tE9svA02P5g3ezRED9/DLeH qz8ybKopeVvNo/XBmK5pXJQ0Gkjaf6lOqqMMFiwOmrqTIhF/jWdN9OjSAPnBy83dhlsg 31wAk8E5JfPxeZeIhBpUPWCFvJCVX8KvlKQLSrHUv8SeSVV8m5xCt0SjyImWkBCyEl/F ZUvMh34FXi8uvV3x+fa1ZKRLxp6euxfKHciVtlJ2Wd2NNYnLG+cMJn0We34+K/CkEEZP VGRA== X-Gm-Message-State: AOAM532e8jzMJCTAjjClP/uIJHVJaOAatFTr5KV0z2Z99f/EVcEfGXw3 PBWw/EwmxGtdHrKFsjwJ6k7cdgH/0tkJ6sTj6J49aKqRv3Y= X-Google-Smtp-Source: ABdhPJwBnP49oaiIyljbR8eBlwkOnsUuUCeVvFp4PwqEVi4CfSbOJCn2N4Liu+NDvi8XsGRPAZ38jNdsPFDaMw4Z6gY= X-Received: by 2002:adf:e38d:: with SMTP id e13mr1987386wrm.402.1639525485307; Tue, 14 Dec 2021 15:44:45 -0800 (PST) X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42c (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=stefan.itampe@gmail.com; helo=mail-wr1-x42c.google.com X-Spam_score_int: 6 X-Spam_score: 0.6 X-Spam_bar: / X-Spam_report: (0.6 / 5.0 requ) BAYES_40=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 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:17851 Archived-At: Maybe you think the below program is trivial, but I adore named let's so much that I just cannot fathom that when people go functional they totally miss this beauty (define (count tree) ;; s = total sum up to now ;; t = tree of the type (car = child . cdr = siblings) ;; cont is the continuation, (cont 10) will continue ;; the calculation with the sum=10 see how we initiate ;; with a continuation that evaluates returns it's argument (let loop ((s 0) (t tree) (cont (lambda (s) s))) (if (pair? t) (loop s (car t) (lambda (s) (loop s (cdr t) cont))) (cont (if (number? t) t 0))))