Welcome to my little node on the network! My name is Petar, you can follow me here while I'm figuring out how computers work.

Recent posts

Running to think

For a few years now, I've been partaking in the age-old ritual of running. I began my journey like many others, swathed in quality athletic wear and armed with a meticulous training schedule...

Read more

Recent notes

Piping arithmetic in Elixir

For an exercism exercise I wanted to do multiplication with the pipe operator, and simply using * does not work, neither does (*).

Now, it turns out the arithmetic operations are functions part of the Kernel module, and you can also call them as an actual function with Kernel.*(2, 2), which is equal to writing 2 * 2.

This enables you do do arithmetic as part of the pipe operation, see:

def monthly_rate(hourly_rate, discount) do
  |> daily_rate
  |> apply_discount(discount)
  |> Kernel.*(22)
  |> ceil()


Recent reads