| Deutsch English Français Italiano |
|
<103bjo0$198dk$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: "B. Pym" <Nobody447095@here-nor-there.org> Newsgroups: comp.lang.lisp Subject: Re: newbie asks: why CL rather than scheme? Date: Mon, 23 Jun 2025 13:10:25 -0000 (UTC) Organization: A noiseless patient Spider Lines: 24 Message-ID: <103bjo0$198dk$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Injection-Date: Mon, 23 Jun 2025 15:10:25 +0200 (CEST) Injection-Info: dont-email.me; posting-host="0e19d3e07ace9ea1c3737f1da44f9ec9"; logging-data="1352116"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+GNYl1bdrBuUdJfcYRlIOl" User-Agent: XanaNews/1.18.1.6 Cancel-Lock: sha1:q6d5UW6kGciGBpHp4RY1f34PZUU= K. M. Pitman wrote: > but instead of the LOOP version above you would probably write: > > (define (add-up number-list) > (let continue ((remaining-items number-list) (sum-so-far 0)) > (if (null? remaining-items) > sum-so-far > (add-up (cdr remaining-items) > (+ sum-so-far (car remaining-items)))))) Wrong. You didn't even use "continue". Understand? Gauche Scheme (do ((sum 0 (+ sum (pop! nums)))) ((null? nums) sum)) Another way. (use srfi-42 :only (sum-ec)) (define (add-up number-list) (sum-ec (:list x number-list) x))