Days 12 & 13: Homework

Yesterday I spent my time completing the bash tutorial and going through the Haskell book.

Here is something I came accross in the Haskell book yesterday, regarding function composition:

(.) :: [1](b -> c) -> [2](a -> b) -> [3](a -> c)

In English:
1. given a function b to c
2. given a function a to b
3. return a function a to c

The result of (a -> b) is the argument of (b -> c) so this is how we get from an a argument to a c result. We’ve stitched the result of one function into being the argument of another.”

This is another example of initially being very confused as a result of overthinking. I think point 3 is what really tripped me up. The wording of “returning a function” is weird to me, but the book does a nice job of explaining what exaclty happens. And for that, I am very grateful 😄.

I also spoke with Wolfram and Markus (Scheuermann, not Heilig) about potential additions to Ugurcan’s Heartbeat project. We discussed making the information more personal, with hopes to spark conversation. Markus said something like “information that encourages action.” I think that’s a good mindset to have going forward with this project. Wolfram and I briefly discussed our first step: Come up with a way to have multiple urls on rotation, where one can easily add/remove urls displaying different information. Exciting!

Today I did more Haskell and read some of the Software Crafter book. I also spent some time refreshing my memory on the short stories of Jorge Luis Borges (this urge was sparked when I saw the Haskell book quote him at the beginning of the recursion chapter), and I stumbled accross some information that he was incredibly racist and said awful things about black people. That was a disappointing tangent to which, oddly enough, the Haskell book led me.

But back to the main path of focus: Recursion, hooray! Here’s one of the first examples they give, where a number n is incremented times times:

incTimes :: (Eq a, Num a) => a -> a -> a
incTimes 0 n = n
incTimes times n = 1 + (incTimes (times - 1) n)

Then the function is called like so:
Prelude> incTimes 10 0
Prelude> incTimes 5 0
Prelude> incTimes 5 5

The only unintuitive thing, for me, is seeing incTimes 0 n = n. It’s strange to see how this is how base cases (and, similarly, conditionals) are defined. It’s just weird not to see an if in there.

Otherwise, things are smooth sailing with Haskell. Things are also smooth sailing regarding my Bürgerbüro visits… I finally got my tax ID!!!! The next step is the Ausländerbehörde, which is even more complicated and even more inaccessible 😅.

More on recursion tomorrow 😄

Last updated: