Esempio n. 1
0
        public static Goal Distincto(this KRunner k, params object[] vs)
        {
            if (vs.Length < 2)
            {
                return(k.Succeed);
            }
            if (vs.Length == 2)
            {
                return(k.Noto(k.Eq(vs[0], vs[1])));
            }
            var gs = Enumerable.Empty <Goal>().ToList();

            for (var i = 0; i < vs.Length; ++i)
            {
                for (var j = i + 1; j < vs.Length; ++j)
                {
                    gs.Add(k.Noto(k.Eq(vs[i], vs[j])));
                }
            }
            return(k.All(gs.ToArray()));
        }
Esempio n. 2
0
 public static Goal Noto(this KRunner k, params Goal[] gs)
 {
     if (gs.Length == 0)
     {
         return(k.Succeed);
     }
     if (gs.Length == 1)
     {
         return(k.If(gs[0], k.Fail, k.Succeed));
     }
     return(k.All(gs.Select(g => k.Noto(g)).ToArray()));
 }