On Thursday, 5 April 2018 at 08:57:11 UTC, SimonN wrote:
On Thursday, 5 April 2018 at 08:12:38 UTC, aerto wrote:
This is the bitcoin genesis block merkle root 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b how i can get it at this format 3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a ??

i try it using

string merkle = "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";

writeln(merkle.retro.text); and it gives me


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 =
        assert (merkle.retro.equal(
        assert (merkle.chunks(2).array.retro.joiner.equal(

-- Simon

FYI: The problem isn't chunks, but that strings aren't bi-directional ranges (hello ugly auto-decoding!).
Simply disable it with byCodeUnit:

import std.experimental.all;
void main()
"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b".byCodeUnit.chunks(2).retro.joiner.writeln; "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b".byCodeUnit.slide(2, 2).retro.joiner.writeln;

Oh and the new slide is a generalization of chunks.


Reply via email to