merkle reverse

drug drug2004 at bk.ru
Thu Apr 5 09:00:05 UTC 2018


05.04.2018 11:57, SimonN пишет:
> 
> Here's one solution with std.range.chunks. A small downside is that it 
> needs the array allocation in the middle because chunks cannot offer the 
> bi-directional range necessary for retro.
> 
>      import std.range;
>      import std.algorithm;
> 
>      void main()
>      {
>          string merkle =
> "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";
>          assert (merkle.retro.equal(
> "b33adedfa7b7212ba77cc2e37667f816f78cb13c88a81523a3f98baab4e1e5a4"));
>          assert (merkle.chunks(2).array.retro.joiner.equal(
> "3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a"));
>      }
> 
> -- Simon

It's a pity that retro can't work with chunks without array, it would be 
really nice!


More information about the Digitalmars-d-learn mailing list