From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.ada Subject: Re: Haskell, anyone? Date: Tue, 17 Nov 2015 20:36:28 -0800 Organization: A noiseless patient Spider Message-ID: <874mgjnctv.fsf@nightsong.com> References: <14533506-4289-4148-b8c4-e970f5778b26@googlegroups.com> <87si45msuz.fsf@nightsong.com> <35d6dc4f-4f2e-4e75-925c-e4acc7c8f112@googlegroups.com> <76ea0bc9-537b-4c68-a728-4f634cf6de52@googlegroups.com> <87a8qccxj4.fsf@nightsong.com> <0ff849e9-11d7-438d-abf9-853f79348640@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="560a36ee31cc4bcf69e115b311f0cc5c"; logging-data="10207"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XIxBiHB5joCEg4oltJatG" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:5qo7YyJc440DOlffD/prIL96zp0= sha1:oYOUbJnkuxWA3wDsIcEJw1nvbdc= Xref: news.eternal-september.org comp.lang.ada:28435 Date: 2015-11-17T20:36:28-08:00 List-Id: Hadrien Grasland writes: > int iterate_recursion(int n) ... > int iterate_goto(int n) ... > > You have to admit that in the end, the basic approach is almost > exactly the same, ..."okay, so at the start of the iteration, the input > parameter is indeed n, but after that, we'll decrement it..." I don't think so. In the recursive version, n never changes in the context of the function being run. The function is called again with a new value. Anyway it's not a big deal, there may be some times when an iterative loop is slightly more natural, but writing it recursively is always easy anyway. There are much bigger issues in FP that take a really different approach to deal with. For example, the entire topic of functional data structures. Another is the programs-as-proofs concept in type theory (Haskell doesn't quite reach there seriously, but Agda does). Recursion vs iteration is a tiny step along the way. > Hence my claim that recursion is, indeed, the ultimate goto, including > when it comes to ease of understanding. Guy Steele will be most > pleased. IIRC, he called lambda the ultimate goto because tail calls can be compiled into jumps. No biggie. If you read about continuations in Scheme, they're a heck of a lot more confusing than recursion. ;-)