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

.

parent a0e6b1bf
No related branches found
No related tags found
No related merge requests found
File added
......@@ -37,10 +37,8 @@ def balancedParantheses(terme):
stack.pop()
else:
return False
if len(stack) == 0:
return True
else:
return False
return len(stack) == 0
def parantheses_couples(terme):
assert balancedParantheses(terme), "Not balanced Terme"
......@@ -115,12 +113,6 @@ def buildApp(terme):
t = new_app(t, buildTerm(liste_de_termes[k]))
return t
A = "#x.(x)(y)"
def buildTerm(terme):
TermType = checkType(terme)
if isVariable(terme): return buildVar(terme)
......@@ -139,9 +131,9 @@ def remove_first_and_last_spaces(terme):
j -=1
return "".join([str(letter) for letter in new_terme])
def remove_inutile_spaces(terme):
if parantheses_couples(terme) == 1 and terme[0] == '(' and terme[-1] == ")":
return terme[1:-1]
def remove_inutile_parentheses(terme):
if parantheses_couples(terme) == 1:
return terme[+1:findClosingParanthesesIndex(terme,0)]
else:
return terme
......@@ -155,16 +147,4 @@ def getTermsFromParantheses(terme):
return terms
print(getTermsFromParantheses("(AAAAAA)(BBBBBBBBB)(CCCCCCCCC)"))
print(buildTerm(A))
print(remove_first_and_last_spaces('ll'))
print(isAbstraction(A))
print(isApplication("(x)(y)(z)"))
print(checkType("(#x.x)"))
print(buildTerm('(#x.x)(#y.y)'))
print(remove_inutile_spaces('(#x.x)(#y.y)'))
# print(open_parantheses_counter('((((((((((('))
# print(close_parantheses_counter('((((((((((()'))
# print(buildAbs("#x.ABC"))
# print(checkType("(#x.xx)(fds)"))
# print(findClosingParanthesesIndex('()',0))
\ No newline at end of file
def cleaner(terme):
\ No newline at end of file
......@@ -54,4 +54,21 @@ print((beta_reduction(E)))
print(x)
print(beta_reduction_totale(E))
print(to_string([APP, [APP, [ABS, x, y], y] , z]))
print(beta_reduction_totale(Y_COMBINATOR))
\ No newline at end of file
# print(beta_reduction_totale(Y_COMBINATOR))
#############################################################################################################################
from parser import *
A = "#x.(x)(y)"
print(getTermsFromParantheses("(AAAAAA)(BBBBBBBBB)(CCCCCCCCC)"))
print(buildTerm(A))
print(remove_first_and_last_spaces('ll'))
print(isAbstraction(A))
print(isApplication("(x)(y)(z)"))
print(checkType("(#x.x)"))
print(buildTerm('(#x.x)(#y.y)'))
print(remove_inutile_spaces('(#x.x)(#y.y)'))
# print(open_parantheses_counter('((((((((((('))
# print(close_parantheses_counter('((((((((((()'))
# print(buildAbs("#x.ABC"))
# print(checkType("(#x.xx)(fds)"))
# print(findClosingParanthesesIndex('()',0))
\ 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