using System.Collections.Generic; using System.Linq; namespace hw6cs { public class Condition { public char Name { get; private set; } public bool IsTrue { get; private set; } public Condition(char name, bool tf) { Name = name; IsTrue = tf; } public Condition Clone() { return new Condition(Name, IsTrue); } public Condition Negate() { return new Condition(Name, !IsTrue); } public bool Equals(Condition other) { return Name == other.Name && IsTrue == other.IsTrue; } } public class Variable { public double Probability { get; private set; } public IEnumerable Conditions { get; private set; } public Variable(IEnumerable conditions, double probability) { Probability = probability; Conditions = conditions; } public Variable Negate() { return new Variable( Conditions.Take(1).Select(c => c.Negate()) .Concat(Conditions.Skip(1)), 1.0 - Probability); } //public bool Join(Variable other, char condition) //{ //} } class Program { static void Main(string[] args) { //var pa = new List { new Variable(new[] { new Condition('a', true) }, .01) }; //var pta = new List { // new Variable(new[] { new Condition('t', true), new Condition('a', true) }, .05), // new Variable(new[] { new Condition('t', true), new Condition('a', false) }, .01) }; //var ps = new List { new Variable(new[] { new Condition('s', true) }, .50) }; //from ac in pa //join tac in pta on ac.Join(tac, 'a') into ha } } public }