|
|
|
|
|
by recursive
4342 days ago
|
|
Here's my C# solution that uses no global state, and features a cool (I think) variadic lambda. using System;
using System.Linq;
class Program {
static void Main() {
Console.WriteLine(g("al"));
Console.WriteLine(g()("al"));
Console.WriteLine(g()()("al"));
Console.WriteLine(g()()()("al"));
Console.WriteLine("Press any key to continue.");
Console.ReadKey();
}
delegate dynamic Goal(params string[] args);
static dynamic g(string suffix = null, string prefix = "g") {
if (suffix == "al") return prefix + suffix;
return (Goal)(a => g(a.FirstOrDefault(), prefix + "o"));
}
}
It was a fun exercise. I found that creating a github pull request was not such a fun exercise, and took about 10x longer than the actual task at hand. Perhaps I could learn to do it more smoothly with practice. |
|