I hereby claim:
- I am schoeke on github.
- I am andrej (https://keybase.io/andrej) on keybase.
- I have a public key whose fingerprint is 828C 6C36 999F 8EA9 1C09 701A B802 D6C4 D25E 5E87
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
This is a pretty complicated task, if you only just learned about recursion.
I will walk you through my thinking and then show you the code that I came up with.
Why recursion? Nested datatypes are hard to handle, especially if they can be arbitrarily nested. Recursion is a fine way of dealing with that.
What is this task similar to? Often, you can find a problem where you know the solution to and change that slightly. An average of a list of integers is the sum of the lists' elements divided by the length of the list. The length of the list is trivial, so what about the sum of a list? Easy! Iterate over the list and add the current element to the total. But nested lists?