Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon-compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
typon
typon-compiler
Commits
c5dfd645
Commit
c5dfd645
authored
Apr 04, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add fibonacci fork+sequential tests
parent
f5e72370
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
trans/tests/naive_fibonacci_fork.py
trans/tests/naive_fibonacci_fork.py
+4
-12
trans/tests/naive_fibonacci_sequential.py
trans/tests/naive_fibonacci_sequential.py
+10
-0
No files found.
trans/tests/naive_fibonacci_fork.py
View file @
c5dfd645
from
typon
import
fork
,
sync
from
typon
import
fork
,
sync
def
fibo
(
n
)
:
def
fibo
(
n
:
int
)
->
int
:
if
n
<
2
:
if
n
<
2
:
return
n
return
n
a
=
fibo
(
n
-
1
)
a
=
fork
(
lambda
:
fibo
(
n
-
1
))
b
=
fibo
(
n
-
2
)
b
=
fork
(
lambda
:
fibo
(
n
-
2
))
sync
()
return
a
+
b
return
a
+
b
#def fibo(n: int) -> int:
# if n < 2:
# return n
# a = fork(lambda: fibo(n - 1))
# b = fork(lambda: fibo(n - 2))
# sync()
# return a + b
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
print
(
fibo
(
30
))
# should display 832040
print
(
fibo
(
30
))
# should display 832040
\ No newline at end of file
trans/tests/naive_fibonacci_sequential.py
0 → 100644
View file @
c5dfd645
def
fibo
(
n
):
if
n
<
2
:
return
n
a
=
fibo
(
n
-
1
)
b
=
fibo
(
n
-
2
)
return
a
+
b
if
__name__
==
"__main__"
:
print
(
fibo
(
30
))
# should display 832040
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment