Hi.<br><br><div class="gmail_quote">On 25 September 2011 18:10, Brent Yorgey <span dir="ltr"><<a href="mailto:byorgey@seas.upenn.edu">byorgey@seas.upenn.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
You must at least agree that it is short. </blockquote></div><div><br></div>Not trying to start language wars here, but it is not terribly short for what it does. The following code does the same thing in C#, and isn't far longer. And it has more or less a one-to-one correspondence to the given Haskell code; open a file for reading, open a file for writing, read some number of bytes, apply the transformation, write it to the output file. Flushing the input/output buffers and closing the files are handled by the using construct, similar to withFile in the Haskell example. <div>
<div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">int chunksize = 4096;</font></div><div><font class="Apple-style-span" face="'courier new', monospace">using (var r = new BinaryReader(File.OpenRead("infile")))</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> using (var w = new BinaryWriter(File.OpenWrite("outfile")))</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> for (var buffer = r.ReadBytes(chunksize); buffer.Length > 0; buffer = r.ReadBytes(chunksize))</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> w.Write(Array.ConvertAll(buffer, p => (byte) ~p));</font></div><br clear="all"><div>I think the habit of using quite a few operators in Haskell does make the learning curve steeper.</div>
<div><br></div><div>I am not trying to say that the C# code is <i>better. </i>Just that the Haskell code is not terribly short in this case and it can be a bit cryptic for a newbie.</div><div><br></div><div>Best,</div><div>
Ozgur</div>
</div></div>