Day 5: Haskell

TLDR : Chilling and built-in functions

CaptainLazarus
1 min readJan 15, 2022

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.

Output = 49
  • 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.

Output = [1, 4, 9, 16, 25]
  • $

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)

Output = [8,10]
  • 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.

Output = [4,5]

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)

--

--

CaptainLazarus

I do stuff. Like stuff about code. And book stuff. And gaming stuff. And stuff about life. And stuff about stuff.