Guidelines
When solving the homework, strive to create not just code that works, but code that is readable and concise. Try to write small functions which perform just a single task, and then combine those smaller pieces to create more complex functions.
Don’t repeat yourself: write one function for each logical task, and reuse functions as necessary.
Don't be afraid to introduce new functions where you see fit.
Each task has corresponding source file in src directory where you should implement the solution.
All solutions should compile without warnings with following command:
stack buildYou can and should run automated tests before pushing solution to GitHub via
stack test --test-arguments "-p TaskX"where X in TaskX should be number of corresponding Task to be tested.
So to run all test for the first task you should use following command:
stack test --test-arguments "-p Task1"You can also run tests for all tasks with just
stack testFor debugging you should use GHCi via stack:
stack ghciYou can then load your solution for particular task using :load TaskX command.
Here is how to load Task1 in GHCi:
$ stack ghci
ghci> :load Task1
[1 of 1] Compiling Task1 ( .../src/Task1.hs, interpreted )
Ok, one module loaded.Note: if you updated solution, it can be quickly reloaded in the same GHCi session with
:reloadcommandghci> :reload
Implement factorial of n.
factorial :: IntegerExample:
>>> factorial 0
1
>>> factorial 5
120Implement "sumtorial" of n.
sumtorial :: IntegerExample:
>>> sumtorial 0
1
>>> sumtorial 5
16