internal bool CanInline() { var nodes = Block.Nodes; var isInline = YCombinator.Y <Node, bool>(self => node => { var block = node as Block; if (block != null) { return(block.Nodes.All(self)); } var text = node as Text; var tag = node as Tag; return(text != null || (tag != null && tag.IsInline)); }); // Empty tag if (!nodes.Any()) { return(true); } // Text-only or inline-only tag if (1 == nodes.Count) { return(isInline(nodes.First())); } // Multi-line inline-only tag if (Block.Nodes.All(isInline)) { for (int i = 1, len = nodes.Count; i < len; ++i) { if (nodes[i - 1] as Text != null && nodes[i] as Text != null) { return(false); } } return(true); } // Mixed tag return(false); }
public static NumeralWrapper Factorial(this NumeralWrapper numeral) => YCombinator <NumeralWrapper, NumeralWrapper> .Y(Factorial)(numeral);