From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Nala Ginrut Newsgroups: gmane.lisp.guile.user Subject: Re: why I love scheme Date: Wed, 15 Dec 2021 09:21:47 +0800 Message-ID: References: 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="13504"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Guile User To: Stefan Israelsson Tampe Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Dec 15 02:28:30 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 1mxJ5q-0003Is-AK for guile-user@m.gmane-mx.org; Wed, 15 Dec 2021 02:28:30 +0100 Original-Received: from localhost ([::1]:56932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mxJ5p-0007Jm-4R for guile-user@m.gmane-mx.org; Tue, 14 Dec 2021 20:28:29 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:36270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mxIzb-00036x-Ht for guile-user@gnu.org; Tue, 14 Dec 2021 20:22:04 -0500 Original-Received: from [2a00:1450:4864:20::22f] (port=40463 helo=mail-lj1-x22f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mxIzZ-0006hs-Pz for guile-user@gnu.org; Tue, 14 Dec 2021 20:22:03 -0500 Original-Received: by mail-lj1-x22f.google.com with SMTP id u22so30910919lju.7 for ; Tue, 14 Dec 2021 17:22:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vUHPsOCFE2pyfInr2FHfoKPXZleNEEFvL5LOBLNzj18=; b=BJzTG4tXEileN9sP8n7cTUO2EEQC/nDWuEGb3T01HPuOh5MQWyCL/Bmv0edoX5UeUO p+JuslTap2Cespt7oH4G/KGhQed/CihTP4ih19am2X/kEQ9np+YgfuHM1VU7GetPsKeL CKW3XnV8VHVFqLACirL4kFt4PqIxhgCntVMaYyxLAwg7c3QPIE+Y6IPjCW43wJft+6es 0zNG159SjStDmZMm9RXsId7gcOBqwz4pu8dY3oinZEe2Bmx+6emq+DhSpbDtGfcJXPcb trSqcHdLQ0xD3uRkfSkdb/AFM0WyRvTMtt87uhb7OgEdJWi4bOhwF3ombVNTEQ6zFBup rjGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vUHPsOCFE2pyfInr2FHfoKPXZleNEEFvL5LOBLNzj18=; b=unF1dHvTQGs89gD+VCgzWFvuKSHRDijXcFkY2cuDhftxJr8iWc/5T/qLYd4PNPVot5 99mf2owPHEPj0zmm5Do0dqr5sezbfXH3EMgBC+DY8HMWWPJuDSWbSU19Fk1vF4n3CU0S /U8G2Y6nTVVlkHTDaTF46CFGHz/vcItVdqdz71fWVAylrl8chdHWxoo7m0a19660BvrL KhcQmw8d9IyVTxIWLk79sChEw1hneZSIisaTx7EkK12yD1agZa6XKpgVxUL3lh1m6w9h yR7L8YPQ7Zufv4GPtW7bTgbMyxwTh6lt8tXEELPVVjCQWlRm/rRFMT0solgWghIG5C7f Q9YA== X-Gm-Message-State: AOAM532BZ/BQrFe+lwMN0CrqO+6jL5bLhoc93qSj5T2GLinQcBThQ35K 3FPpuZ/U6yUsczPtNuOCvulPj/YEA3ppKFTt1zk= X-Google-Smtp-Source: ABdhPJzNCuN9XebySEfrbA8SH/tmiHPIMpbD0H/VZX0l10JP4InneMzcEnCF9/o+MCPe/Qg+wVfh1zIJbxRfqfh+BVM= X-Received: by 2002:a2e:5850:: with SMTP id x16mr8103431ljd.122.1639531318817; Tue, 14 Dec 2021 17:21:58 -0800 (PST) In-Reply-To: X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::22f (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=nalaginrut@gmail.com; helo=mail-lj1-x22f.google.com X-Spam_score_int: 1 X-Spam_score: 0.1 X-Spam_bar: / X-Spam_report: (0.1 / 5.0 requ) BAYES_05=-0.5, 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:17852 Archived-At: I see your point. Yes, continuation (CPS) is pretty cool to replace the hidden stack magic for recursive algorithms. :-) Best regards. On Wed, Dec 15, 2021, 07:45 Stefan Israelsson Tampe wrote: > 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)))) >