Playing with Python and Functional Programming (FP) concepts after watching:
The Power of Composition by Scott Wlaschin
-
compose function:
- Implementation:
src/compose.py
👈 Click here to check it out! - Tests:
tests/test_compose.py
- Implementation:
-
pipe function (syntactic sugar):
- Implementation:
src/pipe.py
- Tests:
tests/test_pipe.py
- Implementation:
-
The Think Of A Number game shown in Scott's presentation:
- Implementation:
src/think_of_a_number.py
- Tests:
tests/test_think_of_a_number.py
- Implementation:
-
The solution to the Roman Numerals problem:
- Implementation:
src/roman_numerals.py
- Tests:
tests/test_roman_numerals.py
- Implementation:
-
The "Don't do this in an interview" FizzBuzz solution:
- Implementation:
src/fizzbuzz.py
- Tests:
tests/test_fizzbuzz.py
- Implementation:
To type check the code:
docker-compose run python-fun mypy /code --pretty --config-file=pyproject.toml
To run the tests:
docker-compose run python-fun pytest /code/tests -vv -s
To type check the code, I configured mypy following this article.
I decided to turn-off the mypy rule called warn_return_any to avoid using the # type: ignore
comment when using the pipe function.