Esempio n. 1
0
        public IType Invoke(IType[] args)
        {
            if (args.Length != 2)
            {
                throw new RuntimeException("LDIFF: Exactly 2 arguments required");
            }
            if (!Array.TrueForAll(args, (IType x) => x is null || x is Cons))
            {
                throw new RuntimeException("LDIFF: Invalid Argument type");
            }
            if (args[0] is null)
            {
                return(null);
            }
            Cons c = args[0] as Cons;

            if (c.Equals(args[1]))
            {
                return(null);
            }
            Cons ret = new Cons(c.car, Lisp.nil);
            Cons cur = ret;

            while (c.cdr is Cons d && !d.Equals(args[1]))
            {
                cur.cdr = new Cons(d.car, Lisp.nil);
                cur     = cur.cdr as Cons;
                c       = d;
            }
            return(ret);
        }
Esempio n. 2
0
        public void EqualsDoesValueComparison()
        {
            Cons a = CreateComplicatedCons();
            Cons b = CreateComplicatedCons();

            Expect(a.Equals(b));
            Expect(a, EqualTo(b));
        }