Skip to content
Snippets Groups Projects
Commit 33652c93 authored by Antonio MATTAR's avatar Antonio MATTAR
Browse files

-Added more colors // -Fixed the requirements file // - Added a saveImages...

-Added more colors // -Fixed the requirements file // - Added a saveImages parameter to the beta_reduction_totale function
parent dd1e3549
No related branches found
No related tags found
No related merge requests found
......@@ -25,10 +25,10 @@ def pair(A,B):
return new_abs(f,new_app(new_app(f,A),B))
def getFirstFromPair(p):
return beta_reduction_totale(new_app(p,boolean[True]))
return beta_reduction_totale(new_app(p,boolean[True]),None)
def getSecondFromPair(p):
return beta_reduction_totale(new_app(p,boolean[False]))
return beta_reduction_totale(new_app(p,boolean[False]),None)
def dec_to_lambda_relative_integers(number):
if number >= 0:
......@@ -36,16 +36,24 @@ def dec_to_lambda_relative_integers(number):
return pair(boolean[False], dec_to_church(number))
def succ(n):
return beta_reduction_totale(new_abs(f,new_abs(x,new_app(new_app(n,f), new_app(f,x)))))
return beta_reduction_totale(new_abs(f,new_abs(x,new_app(new_app(n,f), new_app(f,x)))),None,False)
def adder(n,m):
return beta_reduction_totale(new_app(new_app(m,succs),n))
return beta_reduction_totale(new_app(new_app(m,succs),n),None)
def power(n,m):# retourne n puiss m
return beta_reduction_totale(new_app(m,n))
return beta_reduction_totale(new_app(m,n),None)
def multiplication(n,m):
return beta_reduction_totale(new_abs(f,new_abs(x,new_app(m,new_app(n,f)))))
return beta_reduction_totale(new_abs(f,new_abs(x,new_app(m,new_app(n,f)))),None)
def is_zero(n):
return beta_reduction_totale(new_app(new_app(n,new_abs(x,boolean[False])),boolean[True]))
return beta_reduction_totale(new_app(new_app(n,new_abs(x,boolean[False])),boolean[True]),None)
j= new_abs(x,new_abs(y,new_app(new_app(is_zero(new_app(x,dec_to_church(1))),y),succ(new_app(x,y)))))
def predec(n):
return beta_reduction_totale(new_app(new_app(new_app(n,j),new_abs(z,dec_to_church(0))),dec_to_church(0)),None,False)
print((predec(dec_to_church(2))))
\ No newline at end of file
figures/alligator_brown.png

48 KiB

figures/alligator_oceanblue.png

26.4 KiB

figures/egg_brown.png

8.8 KiB

figures/egg_oceanblue.png

10.2 KiB

figures/egg_yellow.png

5.99 KiB | W: | H:

figures/egg_yellow.png

11.4 KiB | W: | H:

figures/egg_yellow.png
figures/egg_yellow.png
figures/egg_yellow.png
figures/egg_yellow.png
  • 2-up
  • Swipe
  • Onion skin
figures/space.png

2.51 KiB

......@@ -201,7 +201,12 @@ def captureImage(terme, path):
image_maker.saveImage(image_maker.createImage(terme),str(image_counter),path)
image_counter += 1
def beta_reduction_totale(terme, path):
def beta_reduction_totale(terme, path, saveImages=True):
if saveImages == False:
if beta_reduction(terme) != None:
return beta_reduction_totale(beta_reduction(terme), path, False)
return (terme)
else:
if path == None:
captureImage(terme, None)
else:
......@@ -228,8 +233,10 @@ numbers_to_letters = {
14:'n',
15:'v',
16:'f',
17:'ç'
17:'ç',
18:'aa',
19:'bb',
20:'cc',
}
......
......@@ -13,14 +13,14 @@ def delete_images(path):
except Exception as e:
print(e)
def run_beta_reduction_totale(terme,path):
def run_beta_reduction_totale(terme,path='beta_reduction_totale'):
terme = parsing.parseTerm(terme)
os.makedirs(path, exist_ok=True)
if len(os.listdir(path)) > 0:
delete_images(path)
logic.beta_reduction_totale(terme,path)
def run_beta_reduction_interactive_totale(terme,path):
def run_beta_reduction_interactive_totale(terme,path='beta_reduction_interactive_totale'):
terme = parsing.parseTerm(terme)
os.makedirs(path, exist_ok=True)
if len(os.listdir(path)) > 0:
......
......@@ -39,7 +39,7 @@ def run_main_menu():
if choice == 1:
clear()
terme1 = input('Enter a term: ')
main.run_beta_reduction_totale(terme1,'beta_reduction_totale')
main.run_beta_reduction_totale(terme1)
clear()
print('Done!')
time.sleep(1)
......@@ -49,7 +49,7 @@ def run_main_menu():
elif choice == 2:
clear()
terme2 = input('Enter a term: ')
main.run_beta_reduction_interactive_totale(terme2,'beta_reduction_interactive_totale')
main.run_beta_reduction_interactive_totale(terme2)
clear()
print('Done!')
logic.image_counter = 0
......
os
time
pyfiglet
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment