|
|
|
|
|
by ironhaven
549 days ago
|
|
I have used fold for converting strings to a bitset in advent of code let string = "ewfsan";
let bitset = string.bytes().fold(0u32 |acc, ch| acc | 1 << (ch - b'a'));
This is a idiom that I have used many times so this being more consice than a for loop is a plusOf course if you have never seen a syntax before it will make less sense that anything you have seen before |
|