// // OPERATIONS // // // Potencia // public static Language Power(Language A, int n) { var result = new Language(); var copy = A.Copy(); for (int i = 0; i < n; i++) { result = Concatenation(copy, A); copy = Concatenation(copy, A); } return(result); }
// // Kleene Closure // /// <summary> /// /// </summary> /// <param name="A"></param> /// <param name="n"></param> /// <returns></returns> public static Language KleeneClosure(Language A, int n) { // n represents the number of times the concatenation will happen var language = A.Copy(); for (int i = 0; i < n; i++) { language = language + Concatenation(A, language); } language.Charsets.Add("... INFINITE"); // Since it's normal Closure, EMPTY should be first language.Charsets.Insert(0, "EMPTY"); return(language); }