Skip to content

Commit afb15f5

Browse files
authored
Merge pull request #10 from Deric-W/abc
add predefined variables
2 parents 9b067e5 + 09b02c7 commit afb15f5

File tree

7 files changed

+53
-2
lines changed

7 files changed

+53
-2
lines changed

docs/api/terms.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Package terms
44
.. toctree::
55
:maxdepth: 2
66

7+
terms/abc
78
terms/logic
89
terms/arithmetic
910
terms/pairs

docs/api/terms/abc.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Module abc
2+
==========
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
.. automodule:: lambda_calculus.terms.abc
8+
:members:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "lambda_calculus"
3-
version = "3.0.0"
3+
version = "3.1.0"
44
description = "Implementation of the Lambda calculus"
55
requires-python = ">=3.10"
66
keywords = []

src/lambda_calculus/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from .terms import Variable, Abstraction, Application
66

7-
__version__ = "3.0.0"
7+
__version__ = "3.1.0"
88
__author__ = "Eric Niklas Wolf"
99
__email__ = "[email protected]"
1010
__all__ = (

src/lambda_calculus/terms/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"Variable",
1818
"Abstraction",
1919
"Application",
20+
"abc",
2021
"arithmetic",
2122
"logic",
2223
"pairs",

src/lambda_calculus/terms/abc.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/python3
2+
3+
"""Predefined Variables for all ASCII letters"""
4+
5+
from string import ascii_letters
6+
from . import Variable
7+
8+
__all__ = tuple(ascii_letters)
9+
10+
# better IDE autocompletion
11+
a, b, c, d, e, f, g, h, i, j = map(Variable, "abcdefghij")
12+
k, l, m, n, o, p, q, r, s, t = map(Variable, "klmnopqrst")
13+
u, v, w, x, y, z = map(Variable, "uvwxyz")
14+
15+
A, B, C, D, E, F, G, H, I, J = map(Variable, "ABCDEFGHIJ")
16+
K, L, M, N, O, P, Q, R, S, T = map(Variable, "KLMNOPQRST")
17+
U, V, W, X, Y, Z = map(Variable, "UVWXYZ")

tests/terms/test_abc.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/python3
2+
3+
"""Tests for the predefined variables"""
4+
5+
from unittest import TestCase
6+
from string import ascii_letters
7+
from lambda_calculus.terms import Variable, abc
8+
9+
10+
class PredefinedVariablesTest(TestCase):
11+
"""Tests for the predefined variables"""
12+
13+
def test_complete(self) -> None:
14+
"""Check whether all letters exist"""
15+
self.assertEqual(tuple(ascii_letters), abc.__all__)
16+
for letter in ascii_letters:
17+
self.assertTrue(hasattr(abc, letter))
18+
19+
def test_variables(self) -> None:
20+
"""Test the predefined variables"""
21+
for letter in ascii_letters:
22+
variable = getattr(abc, letter)
23+
self.assertIsInstance(variable, Variable)
24+
self.assertEqual(variable.name, letter)

0 commit comments

Comments
 (0)