Deutsch English Français Italiano |
<87edbestmg.fsf@bsb.me.uk> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse <ben.usenet@bsb.me.uk> Newsgroups: comp.lang.c Subject: Re: Recursion, Yo Date: Tue, 09 Apr 2024 11:44:23 +0100 Organization: A noiseless patient Spider Lines: 28 Message-ID: <87edbestmg.fsf@bsb.me.uk> References: <uut24f$2icpb$1@dont-email.me> <uutqd2$bhl0$1@i2pn2.org> <uv2u2a$41j5$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Tue, 09 Apr 2024 10:44:23 +0200 (CEST) Injection-Info: dont-email.me; posting-host="fa324957339a8e3c51ed3c4958d6166a"; logging-data="190708"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/p2l6WReLicjOkbZrokwxtpSVj3VbCXBU=" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:insFUBr5BfFnXzJ5BHrIiHs+R/w= sha1:Yyr/QlNmYaL/6pBbB44AKYBHTCQ= X-BSB-Auth: 1.e52c8e6f61ffb5397744.20240409114423BST.87edbestmg.fsf@bsb.me.uk Bytes: 2268 Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: > On 07.04.2024 11:52, fir wrote: >>> >> okay, there are some class of things that suit good for recursion - and >> its probably good to spot whose they are > > All iterations. (So, basically all code we typically write with 'for' > and 'while' loops.) For example. Plus all the things where emulation > with non-recursive means is cumbersome and complex. (Like operating > on recursive data structures like trees.) > > Actually, you can formally derive the iterative constructs from [a > subset of] the recursive ones (by introducing variables and loops). > > It makes a difference where one comes from. If folks learned coding > from imperative languages they have more problems with a functional > view (and also with recursion, it seems). Here, with "C", we're more > used to 'while' loops and variables, I think. The language used is key. I would not say that recursion is a good fit for "all iterations" when using C. It's significant (or at least note worthy) that the code in the original post was not ISO C and re-writing it in ISO C would show up some of the issues involved, though this task is still a good fit for an explicitly recursive solution. -- Ben.