Пример #1
0
        //
        // Difference
        //
        public static Language Difference(Language A, Language B)
        {
            var result = new Language();

            for (int i = 0; i < A.Charsets.Count; i++)
            {
                if (B.ExistsOnList(A.Charsets[i]) == -1)
                {
                    result.InsertCharset(A.Charsets[i]);
                }
            }

            return(result);
        }
Пример #2
0
        //
        // Concatenation/Product
        //

        /// <summary>
        ///
        /// </summary>
        /// <param name="A"></param>
        /// <param name="B"></param>
        /// <returns></returns>
        public static Language Concatenation(Language A, Language B)
        {
            var result = new Language();

            String ACharset = "", BCharset = "";

            for (int i = 0; i < A.Charsets.Count; i++)
            {
                ACharset = A.Charsets[i];
                for (int j = 0; j < B.Charsets.Count; j++)
                {
                    BCharset = B.Charsets[j];
                    result.InsertCharset((ACharset + BCharset));
                }
            }

            return(result);
        }
Пример #3
0
        //
        // Intersection
        //
        public static Language Intersection(Language languageA, Language languageB)
        {
            var result = new Language();

            String ACharset = "";

            for (int i = 0; i < languageA.Charsets.Count; i++)
            {
                ACharset = languageA.Charsets[i];

                if (languageB.ExistsOnList(ACharset) != -1)
                {
                    result.InsertCharset(ACharset);
                }
            }

            return(result);
        }
Пример #4
0
        //
        // Complement
        //
        public static Language Complement(Language A, Language universe)
        {
            var result = new Language();

            Console.WriteLine("A: " + A.GetCharsets());
            Console.WriteLine("Universe: " + universe.GetCharsets());

            for (int i = 0; i < universe.Charsets.Count; i++)
            {
                if (A.ExistsOnList(universe.Charsets[i]) != -1)
                {
                    continue;
                }
                else
                {
                    result.InsertCharset(universe.Charsets[i]);
                    Console.WriteLine("I: " + i + ", result: " + result.GetCharsets());
                }
            }

            return(result);
        }