Пример #1
0
        static Cons MapVectorToList1(object functionSpecifier, object [] sequence)
        {
            Delegate function = ResolveFunctionSpecifier(functionSpecifier);
            Cons     answer   = null;

            foreach (object element in sequence)
            {
                answer = Cons(function.DynamicInvoke(element), answer);
            }
            return((Cons)CL.Reverse(answer));
        }
Пример #2
0
        static System.Collections.Generic.IList <T> MapVectorToList1 <I, T> (object functionSpecifier, I [] sequence)
        {
            Delegate           function = ResolveFunctionSpecifier(functionSpecifier);
            ConsCollection <T> answer   = null;

            foreach (I element in sequence)
            {
                answer = new ConsCollection <T> ((T)function.DynamicInvoke(element), answer);
            }
            return(CL.Reverse <T> (answer));
        }
Пример #3
0
        static System.Collections.Generic.IList <T> MapCollectionToList1 <T> (object functionSpecifier, ICollection sequence)
        {
            Delegate           function      = ResolveFunctionSpecifier(functionSpecifier);
            ConsCollection <T> reverseAnswer = null;

            foreach (object element in sequence)
            {
                T item = (T)function.DynamicInvoke(element);
                reverseAnswer = new ConsCollection <T> (item, reverseAnswer);
            }
            return(CL.Reverse <T> (reverseAnswer));
        }
Пример #4
0
        static public Cons RemArgs(object [] ra, object key)
        {
            Cons reversedAnswer = null;

            for (int i = 0; i < ra.Length; i += 2)
            {
                if (ra [i] != key)
                {
                    reversedAnswer = new Cons(ra [i + 1], new Cons(ra [i], reversedAnswer));
                }
            }
            return(CL.Reverse(reversedAnswer));
        }
Пример #5
0
        static public ConsCollection <O> Mapcar <O, I> (object functionSpecifier, System.Collections.Generic.ICollection <I> input)
        {
            if (input == null)
            {
                return(null);
            }
            Function1 <O, I>   function = ResolveFunctionSpecifier <Function1 <O, I> > (functionSpecifier);
            ConsCollection <O> answer   = null;

            foreach (I element in input)
            {
                answer = new ConsCollection <O> (function(element), answer);
            }
            return(CL.Reverse(answer));
        }
Пример #6
0
        static public ConsCollection <T> RemoveDuplicates <T> (System.Collections.Generic.IList <T> list)
        {
            if (list == null)
            {
                return(null);
            }
            ConsCollection <T> answer = null;

            foreach (T element in list)
            {
                if ((answer == null) || !((System.Collections.Generic.IList <T>)answer).Contains(element))
                {
                    answer = new ConsCollection <T> (element, answer);
                }
            }
            return(CL.Reverse(answer));
        }
Пример #7
0
        static Cons Evlis(object formlist)
        {
            Cons evaluated = null;

            while (true)
            {
                Cons formpair = formlist as Cons;
                if (formpair != null)
                {
                    evaluated = new Cons(Eval(formpair.Car), evaluated);
                    formlist  = formpair.Cdr;
                }
                else if (formpair == null)
                {
                    return((Cons)CL.Reverse(evaluated));
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
        }
Пример #8
0
        static System.Collections.Generic.IList <T> MapListToList1 <I, T> (object functionSpecifier, ConsCollection <I> sequence)
        {
            Delegate           function = ResolveFunctionSpecifier(functionSpecifier);
            ConsCollection <T> answer   = null;

            while (sequence != null)
            {
                answer = new ConsCollection <T> ((T)function.DynamicInvoke(sequence.Car), answer);
                object temp = sequence.Cdr;
                if (temp == null)
                {
                    break;
                }
                ConsCollection <I> next = temp as ConsCollection <I>;
                if (next == null)
                {
                    throw new NotImplementedException();
                }
                sequence = next;
            }
            return(CL.Reverse <T> (answer));
        }
Пример #9
0
        static Cons MapListToList1(object functionSpecifier, Cons sequence)
        {
            Delegate function = ResolveFunctionSpecifier(functionSpecifier);
            Cons     answer   = null;

            while (sequence != null)
            {
                answer = new Cons(function.DynamicInvoke(sequence.Car), answer);
                object temp = sequence.Cdr;
                if (temp == null)
                {
                    break;
                }
                Cons next = temp as Cons;
                if (next == null)
                {
                    throw new NotImplementedException();
                }
                sequence = next;
            }
            return((Cons)CL.Reverse(answer));
        }
Пример #10
0
 public static ConsCollection <T> Append <T> (System.Collections.Generic.IList <T> left, ConsCollection <T> right)
 {
     return(CL.Reconc <T> (CL.Reverse <T> (left), right));
 }
Пример #11
0
 // Append
 public static object Append(object left, object right)
 {
     return(CL.Reconc(CL.Reverse(left), right));
 }