boring-math.recursive-functions 0.7.1__tar.gz → 0.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- boring_math_recursive_functions-0.8.1/.gitignore +11 -0
- {boring_math_recursive_functions-0.7.1 → boring_math_recursive_functions-0.8.1}/CHANGELOG.md +6 -0
- boring_math_recursive_functions-0.8.1/PKG-INFO +55 -0
- boring_math_recursive_functions-0.8.1/README.rst +31 -0
- {boring_math_recursive_functions-0.7.1 → boring_math_recursive_functions-0.8.1}/pyproject.toml +23 -15
- {boring_math_recursive_functions-0.7.1 → boring_math_recursive_functions-0.8.1}/src/boring_math/recursive_functions/__init__.py +6 -6
- {boring_math_recursive_functions-0.7.1 → boring_math_recursive_functions-0.8.1}/src/boring_math/recursive_functions/cli/__init__.py +1 -1
- boring_math_recursive_functions-0.8.1/tests/test_ackermann.py +50 -0
- boring_math_recursive_functions-0.8.1/tests/test_fibonacci.py +68 -0
- boring_math_recursive_functions-0.7.1/PKG-INFO +0 -117
- boring_math_recursive_functions-0.7.1/README.md +0 -95
- {boring_math_recursive_functions-0.7.1 → boring_math_recursive_functions-0.8.1}/LICENSE +0 -0
- {boring_math_recursive_functions-0.7.1 → boring_math_recursive_functions-0.8.1}/src/boring_math/recursive_functions/cli/ackermann.py +0 -0
- {boring_math_recursive_functions-0.7.1 → boring_math_recursive_functions-0.8.1}/src/boring_math/recursive_functions/cli/py.typed +0 -0
- {boring_math_recursive_functions-0.7.1 → boring_math_recursive_functions-0.8.1}/src/boring_math/recursive_functions/examples.py +0 -0
- {boring_math_recursive_functions-0.7.1 → boring_math_recursive_functions-0.8.1}/src/boring_math/recursive_functions/py.typed +0 -0
{boring_math_recursive_functions-0.7.1 → boring_math_recursive_functions-0.8.1}/CHANGELOG.md
RENAMED
|
@@ -14,6 +14,12 @@ See [Semantic Versioning 2.0.0](https://semver.org).
|
|
|
14
14
|
|
|
15
15
|
## Releases and other important milestones
|
|
16
16
|
|
|
17
|
+
### Version 0.8.0 - PyPI release date 2025-08-04
|
|
18
|
+
|
|
19
|
+
Infrastructure updated, now similar to pythonic-fp projects.
|
|
20
|
+
|
|
21
|
+
First version released under boring-math namespace.
|
|
22
|
+
|
|
17
23
|
### Version 0.7.0 - PyPI release date 2025-07-31
|
|
18
24
|
|
|
19
25
|
First version released under boring-math namespace.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: boring-math-recursive-functions
|
|
3
|
+
Version: 0.8.1
|
|
4
|
+
Summary: Recursive Functions Package
|
|
5
|
+
Keywords: ackermann,fibonacci,recursive,recursive functions
|
|
6
|
+
Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Description-Content-Type: text/x-rst
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Framework :: Pytest
|
|
11
|
+
Classifier: Intended Audience :: Education
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Typing :: Typed
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: pytest>=8.4.1 ; extra == "test"
|
|
18
|
+
Project-URL: Changelog, https://github.com/grscheller/boring-math-recursive-functions/blob/main/CHANGELOG.md
|
|
19
|
+
Project-URL: Documentation, https://grscheller.github.io/boring-math/recursive-functions/development/build/html/releases.html
|
|
20
|
+
Project-URL: Homepage, https://grscheller.github.io/boring-math/blob/main/README.md
|
|
21
|
+
Project-URL: Source, https://github.com/grscheller/boring-math-recursive-functions
|
|
22
|
+
Provides-Extra: test
|
|
23
|
+
|
|
24
|
+
Boring Math - Recursive Functions
|
|
25
|
+
=================================
|
|
26
|
+
|
|
27
|
+
PyPI project
|
|
28
|
+
`boring-math-recursive-functions
|
|
29
|
+
<https://pypi.org/project/boring-math-recursive-functions>`_.
|
|
30
|
+
|
|
31
|
+
The purpose of this project is to explore different ways to efficiently
|
|
32
|
+
implement recursion in Python.
|
|
33
|
+
|
|
34
|
+
Computable recursive functions can be defined with previously defined or even
|
|
35
|
+
not yet defined values. Functions defined using previously well defined values
|
|
36
|
+
having "base cases" are called "primitively recursive functions." Not all
|
|
37
|
+
computable functions are primitively recursive.
|
|
38
|
+
|
|
39
|
+
This PyPI project is part of of the grscheller
|
|
40
|
+
`boring-math namespace projects
|
|
41
|
+
<https://github.com/grscheller/boring-math/blob/main/README.md>`_
|
|
42
|
+
|
|
43
|
+
Documentation
|
|
44
|
+
-------------
|
|
45
|
+
|
|
46
|
+
Documentation for this project is hosted on
|
|
47
|
+
`GitHub Pages
|
|
48
|
+
<https://grscheller.github.io/boring-math/recursive-functions/development/build/html>`_.
|
|
49
|
+
|
|
50
|
+
Copyright and License
|
|
51
|
+
---------------------
|
|
52
|
+
|
|
53
|
+
Copyright (c) 2023-2025 Geoffrey R. Scheller. Licensed under the Apache
|
|
54
|
+
License, Version 2.0. See the LICENSE file for details.
|
|
55
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Boring Math - Recursive Functions
|
|
2
|
+
=================================
|
|
3
|
+
|
|
4
|
+
PyPI project
|
|
5
|
+
`boring-math-recursive-functions
|
|
6
|
+
<https://pypi.org/project/boring-math-recursive-functions>`_.
|
|
7
|
+
|
|
8
|
+
The purpose of this project is to explore different ways to efficiently
|
|
9
|
+
implement recursion in Python.
|
|
10
|
+
|
|
11
|
+
Computable recursive functions can be defined with previously defined or even
|
|
12
|
+
not yet defined values. Functions defined using previously well defined values
|
|
13
|
+
having "base cases" are called "primitively recursive functions." Not all
|
|
14
|
+
computable functions are primitively recursive.
|
|
15
|
+
|
|
16
|
+
This PyPI project is part of of the grscheller
|
|
17
|
+
`boring-math namespace projects
|
|
18
|
+
<https://github.com/grscheller/boring-math/blob/main/README.md>`_
|
|
19
|
+
|
|
20
|
+
Documentation
|
|
21
|
+
-------------
|
|
22
|
+
|
|
23
|
+
Documentation for this project is hosted on
|
|
24
|
+
`GitHub Pages
|
|
25
|
+
<https://grscheller.github.io/boring-math/recursive-functions/development/build/html>`_.
|
|
26
|
+
|
|
27
|
+
Copyright and License
|
|
28
|
+
---------------------
|
|
29
|
+
|
|
30
|
+
Copyright (c) 2023-2025 Geoffrey R. Scheller. Licensed under the Apache
|
|
31
|
+
License, Version 2.0. See the LICENSE file for details.
|
{boring_math_recursive_functions-0.7.1 → boring_math_recursive_functions-0.8.1}/pyproject.toml
RENAMED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
[project]
|
|
2
|
-
name = "boring-math
|
|
3
|
-
version = "0.
|
|
4
|
-
readme = "README.
|
|
2
|
+
name = "boring-math-recursive-functions"
|
|
3
|
+
version = "0.8.1"
|
|
4
|
+
readme = "README.rst"
|
|
5
5
|
requires-python = ">=3.12"
|
|
6
6
|
license = { file = "LICENSE" }
|
|
7
7
|
authors = [{ name = "Geoffrey R. Scheller", email = "geoffrey@scheller.com" }]
|
|
8
|
-
keywords = [
|
|
8
|
+
keywords = [
|
|
9
|
+
"ackermann",
|
|
10
|
+
"fibonacci",
|
|
11
|
+
"recursive",
|
|
12
|
+
"recursive functions",
|
|
13
|
+
]
|
|
9
14
|
classifiers = [
|
|
10
15
|
"Development Status :: 3 - Alpha",
|
|
11
16
|
"Framework :: Pytest",
|
|
@@ -19,20 +24,25 @@ dependencies = []
|
|
|
19
24
|
dynamic = ["description"]
|
|
20
25
|
|
|
21
26
|
[project.urls]
|
|
22
|
-
Changelog = "https://github.com/grscheller/
|
|
23
|
-
Documentation = "https://grscheller.github.io/boring-math/recursive-functions/"
|
|
24
|
-
Homepage = "https://grscheller.github.io/boring-math/"
|
|
25
|
-
Source = "https://github.com/grscheller/
|
|
27
|
+
Changelog = "https://github.com/grscheller/boring-math-recursive-functions/blob/main/CHANGELOG.md"
|
|
28
|
+
Documentation = "https://grscheller.github.io/boring-math/recursive-functions/development/build/html/releases.html"
|
|
29
|
+
Homepage = "https://grscheller.github.io/boring-math/blob/main/README.md"
|
|
30
|
+
Source = "https://github.com/grscheller/boring-math-recursive-functions"
|
|
26
31
|
|
|
27
32
|
[project.scripts]
|
|
28
33
|
ackermann = "boring_math.recursive_functions.cli.ackermann:ackermann_cli"
|
|
29
34
|
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
test = [
|
|
37
|
+
"pytest>=8.4.1",
|
|
38
|
+
]
|
|
39
|
+
|
|
30
40
|
[build-system]
|
|
31
|
-
requires = ["flit_core>=3.
|
|
41
|
+
requires = ["flit_core>=3.12,<4"]
|
|
32
42
|
build-backend = "flit_core.buildapi"
|
|
33
43
|
|
|
34
|
-
[tool.flit.
|
|
35
|
-
|
|
44
|
+
[tool.flit.module]
|
|
45
|
+
name = "boring_math.recursive_functions"
|
|
36
46
|
|
|
37
47
|
[tool.mypy]
|
|
38
48
|
enable_incomplete_feature = ["NewGenericSyntax"]
|
|
@@ -47,17 +57,15 @@ enabled = true
|
|
|
47
57
|
live-mode = true
|
|
48
58
|
strict = true
|
|
49
59
|
report_progress = true
|
|
50
|
-
exclude = ["tests/.*"]
|
|
51
60
|
|
|
52
61
|
[tool.pytest.ini_options]
|
|
62
|
+
addopts = "-ra"
|
|
53
63
|
consider_namespace_packages = true
|
|
64
|
+
testpaths = ["tests/"]
|
|
54
65
|
|
|
55
66
|
[tool.ruff]
|
|
56
67
|
target-version = "py313"
|
|
57
68
|
|
|
58
|
-
[tool.ruff.lint.per-file-ignores]
|
|
59
|
-
"__init__.py" = ["F401"]
|
|
60
|
-
|
|
61
69
|
[tool.ruff.lint.flake8-quotes]
|
|
62
70
|
docstring-quotes = "double"
|
|
63
71
|
|
|
@@ -21,27 +21,27 @@ Package to explore efficient ways to implement recursive functions.
|
|
|
21
21
|
Example recursive functions
|
|
22
22
|
---------------------------
|
|
23
23
|
|
|
24
|
-
- module:
|
|
24
|
+
- module: boring_math.recursive_functions.examples
|
|
25
25
|
|
|
26
26
|
- Ackermann's function
|
|
27
27
|
|
|
28
28
|
- with list
|
|
29
29
|
|
|
30
|
-
- function:
|
|
30
|
+
- function: boring_math.recursive_functions.examples.ackermann_list
|
|
31
31
|
|
|
32
32
|
- Fibonacci sequences
|
|
33
33
|
|
|
34
34
|
- with generators
|
|
35
35
|
|
|
36
|
-
- function:
|
|
37
|
-
- function:
|
|
36
|
+
- function: boring_math.recursive_functions.examples.fibonacci_generator
|
|
37
|
+
- function: boring_math.recursive_functions.examples.rev_fibonacci_generator
|
|
38
38
|
|
|
39
39
|
CLI program entry points
|
|
40
40
|
------------------------
|
|
41
41
|
|
|
42
|
-
- package:
|
|
42
|
+
- package: boring_math.recursive_functions.cli
|
|
43
43
|
|
|
44
|
-
- module:
|
|
44
|
+
- module: boring_math.recursive_functions.cli.ackermann
|
|
45
45
|
|
|
46
46
|
"""
|
|
47
47
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Copyright 2023-2024 Geoffrey R. Scheller
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from boring_math.recursive_functions.examples import ackermann_list
|
|
16
|
+
|
|
17
|
+
class Test_ackerman:
|
|
18
|
+
def test_ack_list(self) -> None:
|
|
19
|
+
assert ackermann_list(0, 0) == 1
|
|
20
|
+
assert ackermann_list(0, 5) == 6
|
|
21
|
+
assert ackermann_list(1, 0) == 2
|
|
22
|
+
assert ackermann_list(1, 1) == 3
|
|
23
|
+
assert ackermann_list(1, 2) == 4
|
|
24
|
+
assert ackermann_list(1, 3) == 5
|
|
25
|
+
assert ackermann_list(1, 4) == 6
|
|
26
|
+
assert ackermann_list(1, 5) == 7
|
|
27
|
+
assert ackermann_list(1, 6) == 8
|
|
28
|
+
assert ackermann_list(1, 7) == 9
|
|
29
|
+
assert ackermann_list(1, 8) == 10
|
|
30
|
+
assert ackermann_list(1, 27) == 29 # inferring from patterns
|
|
31
|
+
assert ackermann_list(2, 0) == 3
|
|
32
|
+
assert ackermann_list(2, 1) == 5
|
|
33
|
+
assert ackermann_list(2, 2) == 7
|
|
34
|
+
assert ackermann_list(2, 3) == 9
|
|
35
|
+
assert ackermann_list(2, 4) == 11
|
|
36
|
+
assert ackermann_list(2, 5) == 13
|
|
37
|
+
assert ackermann_list(2, 6) == 15
|
|
38
|
+
assert ackermann_list(2, 13) == 29 # inferring from patterns
|
|
39
|
+
assert ackermann_list(3, 0) == 5
|
|
40
|
+
assert ackermann_list(3, 1) == 13
|
|
41
|
+
assert ackermann_list(3, 2) == 29 # inferring from patterns
|
|
42
|
+
assert ackermann_list(3, 3) == 61 # inferring from patterns
|
|
43
|
+
assert ackermann_list(3, 4) == 125
|
|
44
|
+
assert ackermann_list(3, 8) == 2045 # not hand computed
|
|
45
|
+
assert ackermann_list(4, 0) == 13
|
|
46
|
+
# assert ackermann(4, 1) == 65533 # not hand computed!
|
|
47
|
+
assert ackermann_list(0, 21) == 22
|
|
48
|
+
assert ackermann_list(4, 0) == ackermann_list(3, 1)
|
|
49
|
+
assert ackermann_list(3, 7) == ackermann_list(2, ackermann_list(3, 6))
|
|
50
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Copyright 2023-2024 Geoffrey R. Scheller
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from boring_math.recursive_functions.examples import fibonacci_generator, rev_fibonacci_generator
|
|
16
|
+
|
|
17
|
+
class Test_fibonacci:
|
|
18
|
+
def test_fib(self) -> None:
|
|
19
|
+
someFibs: list[int] = []
|
|
20
|
+
fibs = fibonacci_generator()
|
|
21
|
+
fib = next(fibs)
|
|
22
|
+
while(fib < 60):
|
|
23
|
+
someFibs.append(fib)
|
|
24
|
+
fib = next(fibs)
|
|
25
|
+
assert someFibs == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
|
|
26
|
+
|
|
27
|
+
someFibs = []
|
|
28
|
+
fib0 = 1
|
|
29
|
+
fib1 = 1
|
|
30
|
+
fibs = fibonacci_generator(fib0, fib1)
|
|
31
|
+
fib = next(fibs)
|
|
32
|
+
while(fib < 90):
|
|
33
|
+
someFibs.append(fib)
|
|
34
|
+
fib = next(fibs)
|
|
35
|
+
assert someFibs == [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
|
|
36
|
+
|
|
37
|
+
someFibs = []
|
|
38
|
+
fib0 = 1
|
|
39
|
+
fib1 = 1
|
|
40
|
+
fibs = rev_fibonacci_generator(fib0, fib1)
|
|
41
|
+
for n in range(10):
|
|
42
|
+
fib = next(fibs)
|
|
43
|
+
someFibs.append(fib)
|
|
44
|
+
assert someFibs == [1, 0, 1, -1, 2, -3, 5, -8, 13, -21]
|
|
45
|
+
|
|
46
|
+
someFibs = []
|
|
47
|
+
fibs = rev_fibonacci_generator()
|
|
48
|
+
for n in range(10):
|
|
49
|
+
fib = next(fibs)
|
|
50
|
+
someFibs.append(fib)
|
|
51
|
+
assert someFibs == [1, -1, 2, -3, 5, -8, 13, -21, 34, -55]
|
|
52
|
+
|
|
53
|
+
someFibs = []
|
|
54
|
+
fibs = rev_fibonacci_generator(5, 3)
|
|
55
|
+
for _ in range(12):
|
|
56
|
+
fib = next(fibs)
|
|
57
|
+
someFibs.append(fib)
|
|
58
|
+
assert someFibs == [3, 2, 1, 1, 0, 1, -1, 2, -3, 5, -8, 13]
|
|
59
|
+
|
|
60
|
+
someFibs = []
|
|
61
|
+
fibs = fibonacci_generator(-55, 34)
|
|
62
|
+
fib = next(fibs)
|
|
63
|
+
while(fib < 90):
|
|
64
|
+
someFibs.append(fib)
|
|
65
|
+
fib = next(fibs)
|
|
66
|
+
assert someFibs == [-55, 34, -21, 13, -8, 5, -3, 2, -1, 1, 0,
|
|
67
|
+
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
|
|
68
|
+
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: boring-math.recursive-functions
|
|
3
|
-
Version: 0.7.1
|
|
4
|
-
Summary: Recursive Functions Package
|
|
5
|
-
Keywords: ackermann,fibonacci,recursive,recursive functions
|
|
6
|
-
Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
|
|
7
|
-
Requires-Python: >=3.12
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
Classifier: Development Status :: 3 - Alpha
|
|
10
|
-
Classifier: Framework :: Pytest
|
|
11
|
-
Classifier: Intended Audience :: Education
|
|
12
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
-
Classifier: Typing :: Typed
|
|
16
|
-
License-File: LICENSE
|
|
17
|
-
Project-URL: Changelog, https://github.com/grscheller/bm-recursive-functions/blob/main/CHANGELOG.md
|
|
18
|
-
Project-URL: Documentation, https://grscheller.github.io/boring-math/recursive-functions/
|
|
19
|
-
Project-URL: Homepage, https://grscheller.github.io/boring-math/
|
|
20
|
-
Project-URL: Source, https://github.com/grscheller/bm-recursive-functions
|
|
21
|
-
|
|
22
|
-
# Boring Math Library - Recursive functions
|
|
23
|
-
|
|
24
|
-
The purpose of this project is to explore different ways to efficiently
|
|
25
|
-
implement recursive functions in Python.
|
|
26
|
-
|
|
27
|
-
## Repos and Documentation
|
|
28
|
-
|
|
29
|
-
### Repositories
|
|
30
|
-
|
|
31
|
-
- [boring-math.recursive-functions][1] project on *PyPI*
|
|
32
|
-
- [Source code][2] on *GitHub*
|
|
33
|
-
|
|
34
|
-
### Detailed documentation
|
|
35
|
-
|
|
36
|
-
- [Detailed API documentation][3] on *GH-Pages*
|
|
37
|
-
|
|
38
|
-
## Overview
|
|
39
|
-
|
|
40
|
-
- Recursive functions
|
|
41
|
-
- [Ackermann Function](#ackermanns-function)
|
|
42
|
-
- [Fibonacci Sequences](#fibonacci-sequences)
|
|
43
|
-
- CLI applications
|
|
44
|
-
- [Ackermann CGI programs](#ackermann-cli-programs)
|
|
45
|
-
|
|
46
|
-
This project is part of the [Boring Math][4] **boring-math** namespace project.
|
|
47
|
-
|
|
48
|
-
### Recursive functions
|
|
49
|
-
|
|
50
|
-
Computable recursive functions can be defined with previously defined or not yet
|
|
51
|
-
defined values. Functions defined using previously defined values having
|
|
52
|
-
"base cases" are called "primitively recursive functions." Not all
|
|
53
|
-
computable functions are primitively recursive.
|
|
54
|
-
|
|
55
|
-
#### Ackermann's Function
|
|
56
|
-
|
|
57
|
-
- Function **ackermann_list**(m: int, n: int) -> int
|
|
58
|
-
- is a total computable function that is not primitive recursive
|
|
59
|
-
- becomes numerically intractable after `m=4`
|
|
60
|
-
- see [CLI section](#ackermann-cli-programs) below for a mathematical definition
|
|
61
|
-
|
|
62
|
-
#### Fibonacci Sequences
|
|
63
|
-
|
|
64
|
-
- Function **fibonacci**(f0: int=0, f1: int=1) -> Iterator[int]
|
|
65
|
-
|
|
66
|
-
- returns a *Fibonacci* sequence iterator where
|
|
67
|
-
- `f(0) = f0` and `f(1) = f1`
|
|
68
|
-
- `f(n) = f(n-1) + f(n-2)`
|
|
69
|
-
- yield defaults to `0, 1, 1, 2, 3, 5, 8, 13, 21, ...`
|
|
70
|
-
|
|
71
|
-
- Function **rev_fibonacci**(f0: int=0, f1: int=1) -> Iterator[int]
|
|
72
|
-
|
|
73
|
-
- returns a *Reverse Fibonacci* sequence iterator where
|
|
74
|
-
- `rf(0) = f0` and `rf(1) = f1`
|
|
75
|
-
- `rf(n) = rf(n-1) - rf(n-2)`
|
|
76
|
-
- `rf(0) = fib(-1) = 1`
|
|
77
|
-
- `rf(1) = fib(-2) = -1`
|
|
78
|
-
- `rf(2) = fib(-3) = 2`
|
|
79
|
-
- `rf(3) = fib(-4) = -3`
|
|
80
|
-
- `rf(4) = fib(-5) = 5`
|
|
81
|
-
- yield defaults to `1, -1, 2, -3, 5, -8, 13, -21, ...`
|
|
82
|
-
|
|
83
|
-
______________________________________________________________________
|
|
84
|
-
|
|
85
|
-
## CLI Applications
|
|
86
|
-
|
|
87
|
-
Implemented in an OS and package build tool independent way via the
|
|
88
|
-
project.scripts section of pyproject.toml.
|
|
89
|
-
|
|
90
|
-
### Ackermann CLI programs
|
|
91
|
-
|
|
92
|
-
Ackermann, a student of Hilbert, discovered early examples of totally
|
|
93
|
-
computable functions that are not primitively recursive.
|
|
94
|
-
|
|
95
|
-
A [fairly standard][5] definition of the Ackermann function is
|
|
96
|
-
recursively defined for `m,n >= 0` by
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
ackermann(0,n) = n+1
|
|
100
|
-
ackermann(m,0) = ackermann(m-1,1)
|
|
101
|
-
ackermann(m,n) = ackermann(m-1, ackermann(m, n-1))
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
#### CLI program **ackermann_list**
|
|
105
|
-
|
|
106
|
-
- Given two non-negative integers, evaluates Ackermann's function
|
|
107
|
-
- Implements the recursion via a Python array
|
|
108
|
-
- **Usage:** `ackerman_list m n`
|
|
109
|
-
|
|
110
|
-
______________________________________________________________________
|
|
111
|
-
|
|
112
|
-
[1]: https://pypi.org/project/boring-math.recursive-functions/
|
|
113
|
-
[2]: https://github.com/grscheller/bm-recursive-functions/
|
|
114
|
-
[3]: https://grscheller.github.io/boring-math/recursive-functions/development/build/html/
|
|
115
|
-
[4]: https://grscheller.github.io/boring-math/
|
|
116
|
-
[5]: https://mathworld.wolfram.com/AckermannFunction.html
|
|
117
|
-
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
# Boring Math Library - Recursive functions
|
|
2
|
-
|
|
3
|
-
The purpose of this project is to explore different ways to efficiently
|
|
4
|
-
implement recursive functions in Python.
|
|
5
|
-
|
|
6
|
-
## Repos and Documentation
|
|
7
|
-
|
|
8
|
-
### Repositories
|
|
9
|
-
|
|
10
|
-
- [boring-math.recursive-functions][1] project on *PyPI*
|
|
11
|
-
- [Source code][2] on *GitHub*
|
|
12
|
-
|
|
13
|
-
### Detailed documentation
|
|
14
|
-
|
|
15
|
-
- [Detailed API documentation][3] on *GH-Pages*
|
|
16
|
-
|
|
17
|
-
## Overview
|
|
18
|
-
|
|
19
|
-
- Recursive functions
|
|
20
|
-
- [Ackermann Function](#ackermanns-function)
|
|
21
|
-
- [Fibonacci Sequences](#fibonacci-sequences)
|
|
22
|
-
- CLI applications
|
|
23
|
-
- [Ackermann CGI programs](#ackermann-cli-programs)
|
|
24
|
-
|
|
25
|
-
This project is part of the [Boring Math][4] **boring-math** namespace project.
|
|
26
|
-
|
|
27
|
-
### Recursive functions
|
|
28
|
-
|
|
29
|
-
Computable recursive functions can be defined with previously defined or not yet
|
|
30
|
-
defined values. Functions defined using previously defined values having
|
|
31
|
-
"base cases" are called "primitively recursive functions." Not all
|
|
32
|
-
computable functions are primitively recursive.
|
|
33
|
-
|
|
34
|
-
#### Ackermann's Function
|
|
35
|
-
|
|
36
|
-
- Function **ackermann_list**(m: int, n: int) -> int
|
|
37
|
-
- is a total computable function that is not primitive recursive
|
|
38
|
-
- becomes numerically intractable after `m=4`
|
|
39
|
-
- see [CLI section](#ackermann-cli-programs) below for a mathematical definition
|
|
40
|
-
|
|
41
|
-
#### Fibonacci Sequences
|
|
42
|
-
|
|
43
|
-
- Function **fibonacci**(f0: int=0, f1: int=1) -> Iterator[int]
|
|
44
|
-
|
|
45
|
-
- returns a *Fibonacci* sequence iterator where
|
|
46
|
-
- `f(0) = f0` and `f(1) = f1`
|
|
47
|
-
- `f(n) = f(n-1) + f(n-2)`
|
|
48
|
-
- yield defaults to `0, 1, 1, 2, 3, 5, 8, 13, 21, ...`
|
|
49
|
-
|
|
50
|
-
- Function **rev_fibonacci**(f0: int=0, f1: int=1) -> Iterator[int]
|
|
51
|
-
|
|
52
|
-
- returns a *Reverse Fibonacci* sequence iterator where
|
|
53
|
-
- `rf(0) = f0` and `rf(1) = f1`
|
|
54
|
-
- `rf(n) = rf(n-1) - rf(n-2)`
|
|
55
|
-
- `rf(0) = fib(-1) = 1`
|
|
56
|
-
- `rf(1) = fib(-2) = -1`
|
|
57
|
-
- `rf(2) = fib(-3) = 2`
|
|
58
|
-
- `rf(3) = fib(-4) = -3`
|
|
59
|
-
- `rf(4) = fib(-5) = 5`
|
|
60
|
-
- yield defaults to `1, -1, 2, -3, 5, -8, 13, -21, ...`
|
|
61
|
-
|
|
62
|
-
______________________________________________________________________
|
|
63
|
-
|
|
64
|
-
## CLI Applications
|
|
65
|
-
|
|
66
|
-
Implemented in an OS and package build tool independent way via the
|
|
67
|
-
project.scripts section of pyproject.toml.
|
|
68
|
-
|
|
69
|
-
### Ackermann CLI programs
|
|
70
|
-
|
|
71
|
-
Ackermann, a student of Hilbert, discovered early examples of totally
|
|
72
|
-
computable functions that are not primitively recursive.
|
|
73
|
-
|
|
74
|
-
A [fairly standard][5] definition of the Ackermann function is
|
|
75
|
-
recursively defined for `m,n >= 0` by
|
|
76
|
-
|
|
77
|
-
```
|
|
78
|
-
ackermann(0,n) = n+1
|
|
79
|
-
ackermann(m,0) = ackermann(m-1,1)
|
|
80
|
-
ackermann(m,n) = ackermann(m-1, ackermann(m, n-1))
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
#### CLI program **ackermann_list**
|
|
84
|
-
|
|
85
|
-
- Given two non-negative integers, evaluates Ackermann's function
|
|
86
|
-
- Implements the recursion via a Python array
|
|
87
|
-
- **Usage:** `ackerman_list m n`
|
|
88
|
-
|
|
89
|
-
______________________________________________________________________
|
|
90
|
-
|
|
91
|
-
[1]: https://pypi.org/project/boring-math.recursive-functions/
|
|
92
|
-
[2]: https://github.com/grscheller/bm-recursive-functions/
|
|
93
|
-
[3]: https://grscheller.github.io/boring-math/recursive-functions/development/build/html/
|
|
94
|
-
[4]: https://grscheller.github.io/boring-math/
|
|
95
|
-
[5]: https://mathworld.wolfram.com/AckermannFunction.html
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|