Fix transposed ranges
Steven Schveighoffer
schveiguy at yahoo.com
Mon Apr 2 18:33:25 UTC 2018
On 3/30/18 4:45 PM, Cym13 wrote:
> On Friday, 30 March 2018 at 20:43:09 UTC, Cym13 wrote:
>> Hi, I've got the following code that takes a list of files as argument
>> and xor them together (demo example sufficient for that discussion).
>>
>> [...]
>
> Forgot to mention but I'm also quite annoyed at the need for that
> ".array" because "transposed" requires the RoR to be assignable. That
> kills the laziness. I'm very much open to suggestions regarding that point.
1. The .save deprecation may not affect you. It's probably being used by
map or fold but may not need to be. Once it's removed, you may just see
the warning go away, and everything still works just fine. I'm not 100%
sure on this, as I don't know where it's being used.
2. The array is necessary, as map is lazy. what you want is a range of
the first byte of each file, then a range of the second byte of each
file, etc. mapping to a byte array can't possibly do this, because what
would happen is that map would re-open the file, re-read it's contents,
and then give you the *second* byte. This is horribly inefficient.
But you can probably reduce the memory requirements by streaming each
file's bytes as you need it. Unfortunately, I don't see a 'byByte'
method on File, so you may have to look elsewhere for that.
-Steve
More information about the Digitalmars-d-learn
mailing list