Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace Caesar
{
static class Program
{
static void Main(string[] args)
@akselqviller
akselqviller / CsPoetomatic.cs
Last active November 18, 2015 13:57
C# keywords poet-omatic
var pageContent = new System.Net.WebClient().DownloadString("https://msdn.microsoft.com/en-us/library/x53a06bb.aspx");
var keywords = new Regex(@".aspx"">(\w+)</a>").Matches(pageContent).Cast<Match>()
.Select(m => m.Groups[1].Value).OrderBy(s => s).ToList();
var rand = new Random();
var poem = string.Join("\n",
Enumerable.Range(0, 3).Select(l => String.Join(" ",
Enumerable.Range(0, rand.Next(1, 5))
.Select(w => keywords[rand.Next(keywords.Count)]))));
poem.Dump();
private static LinkedTree<SExpNode> BuildTree(string literal, params LinkedTree<SExpNode>[] subNodes)
{
var node = new LinkedTree<SExpNode>(new SExpNode() { Literal = literal });
foreach (var subNode in subNodes)
{
node.AddSubNodeLast(subNode);
}
return node;
}