Day 5: Haskell
TLDR : Chilling and built-in functions
Note : I must admit that GitHub gists is pretty good. The fact that I can embed this makes it a million times better.
Learnt about some built in functions today, and I must admit I like these.
- Function composition (It’s symbol is a dot.)
The function conjugation operator (.) basically lets you combine two functions together.
- map
map basically applies a function to an entire list, like the python map. I’m only testing basics (Int -> Int) for now, but I’ll check with different functions later on.
- $
Funny thing about this operator? Doesn’t actually do anything. Its main purpose is to operate as a syntax cleaner when you have too many functions (As shown below)
- Filter
if you’re wondering about what filter does, I suggest reading the name again. Anyway, it removes elements from a list that don’t satisfy a condition supplied by you.
Side Note: An interesting thing is that you don’t have to define an anonymous function (\x → x>3). You can just put (>3) and the program runs fine. This is applicable for map too, where the anonymous function reduces to simply 2* instead of the usual (\x → 2*x)