Skip to content

Commit

Permalink
Merge pull request #10 from Deric-W/abc
Browse files Browse the repository at this point in the history
add predefined variables
  • Loading branch information
Deric-W authored Apr 10, 2024
2 parents 9b067e5 + 09b02c7 commit afb15f5
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/api/terms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Package terms
.. toctree::
:maxdepth: 2

terms/abc
terms/logic
terms/arithmetic
terms/pairs
Expand Down
8 changes: 8 additions & 0 deletions docs/api/terms/abc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Module abc
==========

.. toctree::
:maxdepth: 2

.. automodule:: lambda_calculus.terms.abc
:members:
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "lambda_calculus"
version = "3.0.0"
version = "3.1.0"
description = "Implementation of the Lambda calculus"
requires-python = ">=3.10"
keywords = []
Expand Down
2 changes: 1 addition & 1 deletion src/lambda_calculus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from .terms import Variable, Abstraction, Application

__version__ = "3.0.0"
__version__ = "3.1.0"
__author__ = "Eric Niklas Wolf"
__email__ = "eric_niklas.wolf@mailbox.tu-dresden.de"
__all__ = (
Expand Down
1 change: 1 addition & 0 deletions src/lambda_calculus/terms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"Variable",
"Abstraction",
"Application",
"abc",
"arithmetic",
"logic",
"pairs",
Expand Down
17 changes: 17 additions & 0 deletions src/lambda_calculus/terms/abc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/python3

"""Predefined Variables for all ASCII letters"""

from string import ascii_letters
from . import Variable

__all__ = tuple(ascii_letters)

# better IDE autocompletion
a, b, c, d, e, f, g, h, i, j = map(Variable, "abcdefghij")
k, l, m, n, o, p, q, r, s, t = map(Variable, "klmnopqrst")
u, v, w, x, y, z = map(Variable, "uvwxyz")

A, B, C, D, E, F, G, H, I, J = map(Variable, "ABCDEFGHIJ")
K, L, M, N, O, P, Q, R, S, T = map(Variable, "KLMNOPQRST")
U, V, W, X, Y, Z = map(Variable, "UVWXYZ")
24 changes: 24 additions & 0 deletions tests/terms/test_abc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/python3

"""Tests for the predefined variables"""

from unittest import TestCase
from string import ascii_letters
from lambda_calculus.terms import Variable, abc


class PredefinedVariablesTest(TestCase):
"""Tests for the predefined variables"""

def test_complete(self) -> None:
"""Check whether all letters exist"""
self.assertEqual(tuple(ascii_letters), abc.__all__)
for letter in ascii_letters:
self.assertTrue(hasattr(abc, letter))

def test_variables(self) -> None:
"""Test the predefined variables"""
for letter in ascii_letters:
variable = getattr(abc, letter)
self.assertIsInstance(variable, Variable)
self.assertEqual(variable.name, letter)

0 comments on commit afb15f5

Please sign in to comment.