public static IEnumerable <Stack <Token> > ReductionOptions(this IEnumerable <Token> proposedStack) { var stack = proposedStack.ToArray(); for (var j = 1; j <= stack.Length && j <= 4; j++) { var head = stack.Subarray(0, j); var tail = stack.Subarray(j, stack.Length - j); if (Sentence.Propose(head)) { var possibleStack = new List <Token>(); possibleStack.Add(new Sentence(head)); possibleStack.AddRange(tail); yield return(possibleStack.ToStack()); } if (VerbPhrase.Propose(head)) { var possibleStack = new List <Token>(); possibleStack.Add(new VerbPhrase(head)); possibleStack.AddRange(tail); yield return(possibleStack.ToStack()); } if (NounPhrase.Propose(head)) { var possibleStack = new List <Token>(); possibleStack.Add(new NounPhrase(head)); possibleStack.AddRange(tail); yield return(possibleStack.ToStack()); } } }