Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Alligators-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin Monmege
Alligators-python
Commits
f39ab522
Commit
f39ab522
authored
2 years ago
by
Tamazouzt AIT ELDJOUDI
Browse files
Options
Downloads
Patches
Plain Diff
added arithmetic expressions to app functions and main
parent
1c0cd91f
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
app_functions.py
+5
-1
5 additions, 1 deletion
app_functions.py
image_maker.py
+2
-2
2 additions, 2 deletions
image_maker.py
logic.py
+2
-5
2 additions, 5 deletions
logic.py
main.py
+88
-32
88 additions, 32 deletions
main.py
with
97 additions
and
40 deletions
app_functions.py
+
5
−
1
View file @
f39ab522
...
@@ -25,6 +25,7 @@ SUB= new_abs(x,new_abs(y,new_app(new_app(y,PRED),x)))
...
@@ -25,6 +25,7 @@ SUB= new_abs(x,new_abs(y,new_app(new_app(y,PRED),x)))
AND
=
new_abs
(
x
,
new_abs
(
y
,
new_app
(
new_app
(
x
,
y
),
FALSE
)))
AND
=
new_abs
(
x
,
new_abs
(
y
,
new_app
(
new_app
(
x
,
y
),
FALSE
)))
OR
=
new_abs
(
x
,
new_abs
(
y
,
new_app
(
new_app
(
x
,
TRUE
),
y
)))
OR
=
new_abs
(
x
,
new_abs
(
y
,
new_app
(
new_app
(
x
,
TRUE
),
y
)))
NOT
=
new_abs
(
x
,
new_abs
(
y
,
new_abs
(
z
,
new_app
(
new_app
(
x
,
z
),
y
))))
NOT
=
new_abs
(
x
,
new_abs
(
y
,
new_abs
(
z
,
new_app
(
new_app
(
x
,
z
),
y
))))
XOR
=
new_abs
(
x
,
new_abs
(
y
,
new_app
(
new_app
(
x
,
new_app
(
new_app
(
y
,
FALSE
),
TRUE
)),
y
)))
#definition des entiers de church
#definition des entiers de church
...
@@ -69,3 +70,6 @@ def dec_to_lambda_relative_integers(number):
...
@@ -69,3 +70,6 @@ def dec_to_lambda_relative_integers(number):
#def predec(n):#done
#def predec(n):#done
# return beta_reduction_totale(new_app(PRED, n),None,True)
# return beta_reduction_totale(new_app(PRED, n),None,True)
#print(to_string(beta_reduction_totale(new_app(new_app(XOR,TRUE),FALSE),None,False)))
#print(to_string(dec_to_lambda_relative_integers(5)))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
image_maker.py
+
2
−
2
View file @
f39ab522
This diff is collapsed.
Click to expand it.
logic.py
+
2
−
5
View file @
f39ab522
...
@@ -210,14 +210,11 @@ def captureImage(terme, path, counter=True, date= True):
...
@@ -210,14 +210,11 @@ def captureImage(terme, path, counter=True, date= True):
def
beta_reduction_totale
(
terme
,
path
,
saveImages
=
True
):
def
beta_reduction_totale
(
terme
,
path
,
saveImages
=
True
):
save_image_choice
=
input
(
"
Voulez vous sauvegarder les images (y/n)?
"
)
if
saveImages
==
False
:
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
:
if
beta_reduction
(
terme
)
!=
None
:
return
beta_reduction_totale
(
beta_reduction
(
terme
),
path
,
False
)
return
beta_reduction_totale
(
beta_reduction
(
terme
),
path
,
False
)
return
(
terme
)
return
(
terme
)
el
if
save_image_choice
==
"
y
"
:
el
se
:
if
path
==
None
:
if
path
==
None
:
captureImage
(
terme
,
None
)
captureImage
(
terme
,
None
)
else
:
else
:
...
...
This diff is collapsed.
Click to expand it.
main.py
+
88
−
32
View file @
f39ab522
...
@@ -17,7 +17,8 @@ main_menu_options = {
...
@@ -17,7 +17,8 @@ main_menu_options = {
2
:
'
Interactive Beta-Reduction
'
,
2
:
'
Interactive Beta-Reduction
'
,
3
:
'
Arithmetic Operations
'
,
3
:
'
Arithmetic Operations
'
,
4
:
'
Show Numbers
'
,
4
:
'
Show Numbers
'
,
5
:
'
Exit
'
,
5
:
'
boolean expression
'
,
6
:
'
Exit
'
,
}
}
arithmetic_operations_options
=
{
arithmetic_operations_options
=
{
...
@@ -35,15 +36,16 @@ choice_number_representation= {
...
@@ -35,15 +36,16 @@ choice_number_representation= {
2
:
'
Relative numbers
'
,
2
:
'
Relative numbers
'
,
3
:
'
Back
'
3
:
'
Back
'
}
}
#vide un repertoire
def
delete_images
(
path
):
boolean_representation
=
{
for
file
in
os
.
listdir
(
path
):
1
:
'
NOT
'
,
file_path
=
os
.
path
.
join
(
path
,
file
)
2
:
'
AND
'
,
try
:
3
:
'
OR
'
,
if
os
.
path
.
isfile
(
file_path
):
4
:
'
XOR
'
,
os
.
unlink
(
file_path
)
5
:
'
IS_ZERO
'
,
except
Exception
as
e
:
6
:
'
back
'
print
(
e
)
}
def
return_main_menu
():
def
return_main_menu
():
not_pressed
=
True
not_pressed
=
True
...
@@ -68,7 +70,13 @@ def run_beta_reduction_totale(terme,path='beta_reduction_totale'):
...
@@ -68,7 +70,13 @@ def run_beta_reduction_totale(terme,path='beta_reduction_totale'):
os
.
makedirs
(
path
,
exist_ok
=
True
)
# cree le rep si il existe pas, le vide si non
os
.
makedirs
(
path
,
exist_ok
=
True
)
# cree le rep si il existe pas, le vide si non
if
len
(
os
.
listdir
(
path
))
>
0
:
if
len
(
os
.
listdir
(
path
))
>
0
:
logic
.
image_counter
=
0
logic
.
image_counter
=
0
logic
.
beta_reduction_totale
(
terme
,
path
)
t
=
logic
.
beta_reduction_totale
(
terme
,
path
)
save_image_choice
=
input
(
'
Do you want to save the image? (y/n):
'
)
while
save_image_choice
not
in
[
'
y
'
,
'
n
'
]:
save_image_choice
=
input
(
'
Invalid choice. Do you want to save the image? (y/n):
'
)
if
save_image_choice
==
'
y
'
:
logic
.
captureImage
(
terme
,
path
)
def
run_beta_reduction_interactive_totale
(
terme
,
path
=
'
beta_reduction_interactive_totale
'
):
def
run_beta_reduction_interactive_totale
(
terme
,
path
=
'
beta_reduction_interactive_totale
'
):
terme
=
parsing
.
parseTerm
(
terme
)
terme
=
parsing
.
parseTerm
(
terme
)
...
@@ -109,6 +117,64 @@ def run_show_numbers(path):
...
@@ -109,6 +117,64 @@ def run_show_numbers(path):
elif
choice
==
3
:
elif
choice
==
3
:
run_main_menu
()
run_main_menu
()
def
run_boolean_expression
(
path
):
os
.
makedirs
(
path
,
exist_ok
=
True
)
print_menu
(
boolean_representation
)
choice
=
int
(
input
(
"
enter your choice :
"
))
while
choice
not
in
boolean_representation
:
clear
()
print_menu
(
boolean_representation
)
choice
=
int
(
input
(
'
Invalid choice. Enter your choice:
'
))
if
choice
==
1
:
clear
()
t
=
app_functions
.
NOT
print
(
'
Voici le terme:
'
,
logic
.
to_string
(
t
))
save_image_choice
=
input
(
'
Do you want to save the image? (y/n):
'
)
while
save_image_choice
not
in
[
'
y
'
,
'
n
'
]:
save_image_choice
=
input
(
'
Invalid choice. Do you want to save the image? (y/n):
'
)
if
save_image_choice
==
'
y
'
:
logic
.
captureImage
(
t
,
path
,
'
NOT
'
,
False
)
elif
choice
==
2
:
clear
()
t
=
app_functions
.
AND
print
(
'
Voici le terme:
'
,
logic
.
to_string
(
t
))
save_image_choice
=
input
(
'
Do you want to save the image? (y/n):
'
)
while
save_image_choice
not
in
[
'
y
'
,
'
n
'
]:
save_image_choice
=
input
(
'
Invalid choice. Do you want to save the image? (y/n):
'
)
if
save_image_choice
==
'
y
'
:
logic
.
captureImage
(
t
,
path
,
'
AND
'
,
False
)
elif
choice
==
3
:
clear
()
t
=
app_functions
.
OR
print
(
'
Voici le terme:
'
,
logic
.
to_string
(
t
))
save_image_choice
=
input
(
'
Do you want to save the image? (y/n):
'
)
while
save_image_choice
not
in
[
'
y
'
,
'
n
'
]:
save_image_choice
=
input
(
'
Invalid choice. Do you want to save the image? (y/n):
'
)
if
save_image_choice
==
'
y
'
:
logic
.
captureImage
(
t
,
path
,
'
OR
'
,
False
)
elif
choice
==
4
:
clear
()
t
=
app_functions
.
XOR
print
(
'
Voici le terme:
'
,
logic
.
to_string
(
t
))
save_image_choice
=
input
(
'
Do you want to save the image? (y/n):
'
)
while
save_image_choice
not
in
[
'
y
'
,
'
n
'
]:
save_image_choice
=
input
(
'
Invalid choice. Do you want to save the image? (y/n):
'
)
if
save_image_choice
==
'
y
'
:
logic
.
captureImage
(
t
,
path
,
'
XOR
'
,
False
)
elif
choice
==
5
:
clear
()
t
=
app_functions
.
IS_ZERO
print
(
'
Voici le terme:
'
,
logic
.
to_string
(
t
))
save_image_choice
=
input
(
'
Do you want to save the image? (y/n):
'
)
while
save_image_choice
not
in
[
'
y
'
,
'
n
'
]:
save_image_choice
=
input
(
'
Invalid choice. Do you want to save the image? (y/n):
'
)
if
save_image_choice
==
'
y
'
:
logic
.
captureImage
(
t
,
path
,
'
IS_ZERO
'
,
False
)
elif
choice
==
6
:
run_main_menu
()
#------------------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------------------
...
@@ -150,6 +216,10 @@ def run_main_menu():
...
@@ -150,6 +216,10 @@ def run_main_menu():
run_show_numbers
(
'
show_numbers
'
)
run_show_numbers
(
'
show_numbers
'
)
return_main_menu
()
return_main_menu
()
elif
choice
==
5
:
elif
choice
==
5
:
clear
()
run_boolean_expression
(
'
boolean expression
'
)
return_main_menu
()
elif
choice
==
6
:
clear
()
clear
()
print
(
good_bye_banner
)
print
(
good_bye_banner
)
...
@@ -165,48 +235,34 @@ def run_arithmetic_operations_menu(path='arithmetic expressions'):
...
@@ -165,48 +235,34 @@ def run_arithmetic_operations_menu(path='arithmetic expressions'):
clear
()
clear
()
print
(
"
Voici le terme:
"
+
logic
.
to_string
(
app_functions
.
ADD
))
print
(
"
Voici le terme:
"
+
logic
.
to_string
(
app_functions
.
ADD
))
logic
.
captureImage
(
app_functions
.
ADD
,
path
,
'
ADD
'
,
False
)
logic
.
captureImage
(
app_functions
.
ADD
,
path
,
'
ADD
'
,
False
)
time
.
sleep
(
1
)
return_main_menu
()
clear
()
run_arithmetic_operations_menu
()
elif
choice
==
2
:
elif
choice
==
2
:
clear
()
clear
()
print
(
"
Voici le terme:
"
+
logic
.
to_string
(
app_functions
.
SUB
))
print
(
"
Voici le terme:
"
+
logic
.
to_string
(
app_functions
.
SUB
))
logic
.
captureImage
(
app_functions
.
SUB
,
path
,
'
SUB
'
,
False
)
logic
.
captureImage
(
app_functions
.
SUB
,
path
,
'
SUB
'
,
False
)
time
.
sleep
(
1
)
return_main_menu
()
clear
()
run_arithmetic_operations_menu
()
elif
choice
==
3
:
elif
choice
==
3
:
clear
()
clear
()
print
(
"
Voici le terme:
"
+
logic
.
to_string
(
app_functions
.
MUL
))
print
(
"
Voici le terme:
"
+
logic
.
to_string
(
app_functions
.
MUL
))
logic
.
captureImage
(
app_functions
.
MUL
,
path
,
'
MUL
'
,
False
)
logic
.
captureImage
(
app_functions
.
MUL
,
path
,
'
MUL
'
,
False
)
time
.
sleep
(
1
)
return_main_menu
()
clear
()
run_arithmetic_operations_menu
()
elif
choice
==
4
:
elif
choice
==
4
:
clear
()
clear
()
print
(
"
Voici le terme:
"
+
logic
.
to_string
(
app_functions
.
POW
))
print
(
"
Voici le terme:
"
+
logic
.
to_string
(
app_functions
.
POW
))
logic
.
captureImage
(
app_functions
.
POW
,
path
,
'
POWER
'
,
False
)
logic
.
captureImage
(
app_functions
.
POW
,
path
,
'
POWER
'
,
False
)
time
.
sleep
(
1
)
return_main_menu
()
clear
()
run_arithmetic_operations_menu
()
elif
choice
==
5
:
elif
choice
==
5
:
clear
()
clear
()
print
(
"
Voici le terme:
"
+
logic
.
to_string
(
app_functions
.
SUCCS
))
print
(
"
Voici le terme:
"
+
logic
.
to_string
(
app_functions
.
SUCCS
))
logic
.
captureImage
(
app_functions
.
SUCCS
,
path
,
'
SUCCS
'
,
False
)
logic
.
captureImage
(
app_functions
.
SUCCS
,
path
,
'
SUCCS
'
,
False
)
time
.
sleep
(
1
)
return_main_menu
()
clear
()
run_arithmetic_operations_menu
()
elif
choice
==
6
:
elif
choice
==
6
:
clear
()
clear
()
print
(
"
Voici le terme:
"
+
logic
.
to_string
(
app_functions
.
PRED
))
print
(
"
Voici le terme:
"
+
logic
.
to_string
(
app_functions
.
PRED
))
logic
.
captureImage
(
app_functions
.
PRED
,
path
,
'
PRED
'
,
False
)
logic
.
captureImage
(
app_functions
.
PRED
,
path
,
'
PRED
'
,
False
)
time
.
sleep
(
1
)
return_main_menu
clear
()
run_arithmetic_operations_menu
()
elif
choice
==
7
:
elif
choice
==
7
:
clear
()
clear
()
run_main_menu
()
run_main_menu
()
run_main_menu
()
run_main_menu
()
input
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment