Gary Willoughby:
I wondered if it was possible to write a classic fizzbuzz[1] example using a UFCS chain? I've tried and failed.
Is this OK? void main() {import std.stdio, std.algorithm, std.range, std.conv, std.functional;
100 .iota .map!(i => ((i + 1) % 15).predSwitch( 0, "FizzBuzz", 3, "Fizz", 5, "Buzz", 6, "Fizz", 9, "Fizz", 10, "Buzz", 12, "Fizz", /*else*/ i.text)) .reverseArgs!writefln("%-(%s\n%)"); } Bye, bearophile