diff --git a/logic.py b/logic.py index 36ef3b816d9297ed058e8b0adbce4f5f7a1f82ad..b707552d82436374de9790cad582280e3e810528 100644 --- a/logic.py +++ b/logic.py @@ -195,7 +195,6 @@ import image_maker image_counter = 0 def captureImage(terme, path, counter=True, date= True): global image_counter - print(counter) if type(counter) == bool and counter: if path == None: image_maker.saveImage(image_maker.createImage(terme),str(image_counter),None,date) @@ -211,11 +210,14 @@ def captureImage(terme, path, counter=True, date= True): def beta_reduction_totale(terme, path, saveImages=True): - if saveImages == False: + save_image_choice = input("Voulez vous sauvegarder les images (y/n)? ") + while save_image_choice not in ["y","n"]: + save_image_choice = input("Voulez vous sauvegarder les images (y/n)? ") + if save_image_choice == "n": if beta_reduction(terme) != None: return beta_reduction_totale(beta_reduction(terme), path, False) return (terme) - else: + elif save_image_choice == "y": if path == None: captureImage(terme, None) else: @@ -224,6 +226,7 @@ def beta_reduction_totale(terme, path, saveImages=True): return beta_reduction_totale(beta_reduction(terme), path) return (terme) + numbers_to_letters = { 0:'x', 1:'y', @@ -432,7 +435,7 @@ def beta_reduction_choice_n(terme,n): def beta_reduction_interactive(terme, at): global counters if at != None: - print(annotated_to_string(at)) + # print(annotated_to_string(at)) choice = int(input("Choose a beta reduction: ")) while choice <= 0 or choice > counters: print("Invalid choice") @@ -457,7 +460,7 @@ def beta_reduction_interactive_totale(terme,path): save_image_choice = int(input("Save image? (1 for yes, 0 for no): ")) if save_image_choice == 1: if beta_reduction((terme)) != None: - print(to_string(terme)) + # print(to_string(terme)) at = (annotate_beta_reduction((terme))) captureImage(at,path) choix=int(input("voulez-vous faire la reduction tapez sur 1 pour oui tapez sur 2 pour non ")) @@ -472,7 +475,7 @@ def beta_reduction_interactive_totale(terme,path): return (terme) else: if beta_reduction((terme)) != None: - print(to_string(terme)) + # print(to_string(terme)) at = (annotate_beta_reduction((terme))) choix=int(input("voulez-vous faire la reduction tapez sur 1 pour oui tapez sur 2 pour non ")) if choix==1: diff --git a/main.py b/main.py index c6e7f07d2036d7ab76d1c4373a7883d7601fb31a..00a3b9336493614958c474e8b6c7d66d7ea45d0d 100644 --- a/main.py +++ b/main.py @@ -24,15 +24,16 @@ arithmetic_operations_options = { 1: 'Addition', 2: 'Subtraction', 3: 'Multiplication', - 4: 'power', - 5: 'successor', - 6: 'predecessor', + 4: 'Power', + 5: 'Successor', + 6: 'Predecessor', 7: 'Back', } choice_number_representation= { - 1: 'integer numbers (church representation)', - 2: 'relative numbers' + 1: 'Integer numbers (church representation)', + 2: 'Relative numbers', + 3: 'Back' } #vide un repertoire def delete_images(path): @@ -105,6 +106,8 @@ def run_show_numbers(path): save_image_choice = input('Invalid choice. Do you want to save the image? (y/n): ') if save_image_choice == 'y': logic.captureImage(t,path,'ENTIER-RELATIF-'+str(terme),False) + elif choice==3: + run_main_menu() @@ -204,4 +207,6 @@ def run_arithmetic_operations_menu(path='arithmetic expressions'): clear() run_main_menu() -run_main_menu() \ No newline at end of file +run_main_menu() + +input() \ No newline at end of file diff --git a/tests.py b/tests.py index bc8f4b1ce9928a4f3d96c65962ddc3bc35a691cc..46e35b5e2b6e4d95b967a157b3f04877ce9f4c12 100644 --- a/tests.py +++ b/tests.py @@ -83,4 +83,6 @@ from logic import * import parsing #print(annotated_to_string(x)) #beta_reduction_interactive_totale(parsing.parseTerm(input("Enter a term: "))) -beta_reduction_interactive_totale(parsing.parseTerm(input("Enter a term: "))) \ No newline at end of file +# beta_reduction_interactive_totale(parsing.parseTerm(input("Enter a term: "))) + +### ADD SAVE IMAGE CHOICE FOR BETA REDUCTION!!!! \ No newline at end of file