Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
typon
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tom Niget
typon
Commits
1d6cf8b4
Commit
1d6cf8b4
authored
Apr 04, 2023
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add fibonacci fork+sequential tests
parent
3487ebcb
Changes
2
Show 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 @
1d6cf8b4
from
typon
import
fork
,
sync
def
fibo
(
n
)
:
def
fibo
(
n
:
int
)
->
int
:
if
n
<
2
:
return
n
a
=
fibo
(
n
-
1
)
b
=
fibo
(
n
-
2
)
a
=
fork
(
lambda
:
fibo
(
n
-
1
))
b
=
fork
(
lambda
:
fibo
(
n
-
2
))
sync
()
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__"
:
print
(
fibo
(
30
))
# should display 832040
\ No newline at end of file
trans/tests/naive_fibonacci_sequential.py
0 → 100644
View file @
1d6cf8b4
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