digitalmars.D - [your code here]
- joe (12/12) Feb 27 2019 void main()
void main() { import std.stdio : writefln; int[char[2]] aa; auto arr = "ABBBA"; // Iterate over all pairs in the string and observe each pair // ('A', 'B'), ('B', 'B'), ('B', 'A'), ... // String slicing doesn't allocate a copy foreach (i; 0 .. arr.length - 1) aa[arr[i .. $][0 .. 2]]++; foreach (key, value; aa) writefln("key: %s, value: %d", key, value);
Feb 27 2019