This is my Implementation to solve the Taktile Coding Challenge For reference the coding challenge is stated as:
Your challenge is to implement
fold
in the language of your choice.fold
is a higher order function that takes5CE2
- a sequence of type A
- a "starting" value of type B
- a function (A, B) -> B
and returns a B. E.g., the
sum
of an array is a special case of fold, where
- the sequence is an array of numbers
- the starting value is 0
- the function is
+
You can find more information on Wikipedia.
Create a conda environment to run this project in isolation (not needed but recommended).
conda env create -f environment.yml
conda activate coding_challenge
pip install --editable .
from coding_challenge.main import fold
fold(iterable=[1,2,3], start=0, fn=lambda x,y: x+y)
Or check the tests/
for more examples of how to run the code
pytest -v tests/