Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Programming exercise/challenge Date: Thu, 10 Dec 2020 21:17:41 -0800 Organization: A noiseless patient Spider Lines: 39 Message-ID: <86tuss2a6i.fsf@linuxsc.com> References: <86wnxwkyol.fsf@linuxsc.com> <871rg2rffu.fsf@bsb.me.uk> <86v9dehts2.fsf@linuxsc.com> <87360hq0si.fsf@bsb.me.uk> <86wnxq2do9.fsf@linuxsc.com> <87eejx9tna.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="d0e6cb8b172339c00630e9a897bd2d9b"; logging-data="19133"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lUvso8Ru4bQCjLoi5KwyhP+eb50dv1rg=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:kxPt2wwm3NR9cCQ60KrOvE+9Dic= sha1:QBCbvLSFRKQNzrNWXBbpyAJ6TsA= Xref: csiph.com comp.lang.c:157214 Ben Bacarisse writes: > Tim Rentsch writes: > >> Ben Bacarisse writes: >> >>> Tim Rentsch writes: >> >> [...] >> >>>>> Haskell has two big advantages for this exercise: pattern matched >>>>> cases and lazy evaluation. [..explanation..] >>>> >>>> Also one not mentioned: 'input <- getContents'. An analogous >>>> functionality in C would read the contents of a file into a >>>> character array, which would make the C program easier. >>> >>> I don't think its analogous at all! 'input' <- getContents does >>> no IO. Input is fetched only as needed to perform computations on >>> 'input' and processed data will be considered garbage. >> >> The point I am trying to make here is not about IO but about data >> structuring. I understand that Haskell has lazy eval and agree >> that there are advantages that accrue from that. Here though I >> think the important property is that getContents returns a "data >> structure" that is convenient to process in Haskell, specifically >> in the context of what an uncommenting program wants to do. An >> analogous data structure in C (not counting the lazy evaluation >> part, which I've already acknowledged) is a character array. >> Let's look at some C code that takes advantage of its primary >> data structure for handling strings. > > As always the problem with "analogous" is what properties are being > considered. I see what you mean now. > > You say it would make the program easier. I wonder if it does. For myself I can say it does. Now that you have looked at what I did, do you still wonder, or has your impression changed?