Hi there 馃憢

Welcome to my blog

A Shell Configuration

I spend a lot of time on the terminal. I started with vanilla terminals on Ubuntu and macOS. Later I learned about terminals with a few "batteries" included like iTerm2 and HyperJS. I have also used tmux extensively before, but ended up switching a few months later to use window splitting from iTerm2 and also profiles, which can login to a shell session automatically. Well, enough of history. This post will introduce you to a basic shell configuration....

April 10, 2020 路 7 min

How to succeed in the software industry

Continuous improvement. This post's purpose is to help students and professionals in the software industry get better at what they do by continuously improving. I share points that helped me mature as a person in the last few years and that, in my humble opinion, made my software developer mind-set much better than when I started. What I show here is not going to make you a great developer, but helps you have ideas on making a plan to become one....

March 31, 2020 路 11 min

One Consumer, Multiple Producers in F#

I have been learning F# by reading the Expert F# 4.0 book by Don Syme, Adam Granicz, et al. I am really enjoying the concurrency chapter and decided to take on a small challenge involving agents (MailboxProcessor). I settled on the following requirements: 1 consumer agent with two-way communication accepts arrays of doubles and stores their sum and count internally allows other to fetch the current average 4 producer agents generate arrays of doubles sends them to the consumer agent fetches the current sum and count waits for a specific interval then generates next one Stats and Messages Let's start by defining a Stats type that will store our sum and count: type Stats = { Count: int; Sum: double; } And also the message type, that our StatsAgent will accept in order to interact with the outside world: type Msg = | Incr of double | Fetch of AsyncReplyChannel<Stats> | Die I don't have any particular comments on the above....

January 5, 2020 路 4 min

Get number of common divisors in OCaml

Hi, everyone! In this challenge I used OCaml sets again. The goal was to get the number of common divisors for each pair of numbers in the test cases. The first function I wrote was to define a limit until when I would be checking if the number was divisible or not: (* Need to check divisors just up to sqrt x *) let max x = Int.of_float (sqrt x) |> (+) 1;; After that, I wrote a function to get the number of common divisors of a single number n....

March 28, 2017 路 3 min

Dedup chars in a string using OCaml

Hi there! The goal of this challenge is to remove all duplicate chars in a string. The following input/output will explain it by itself: # input abcabczabczabc # output abcz I tried to write the functions to explode and implode from what I remembered, but in the end I had to take another look at their code here. Those were auxiliary functions to help me to write remove_all_dups. open Core.Std (* string -> char list *) let explode str = let len = String....

March 27, 2017 路 2 min

Mingle strings in OCaml

Hi there! The problem that I solved this time was a little cumbersome initially, cause even though I knew well how to iterate over lists, I had no idea how to iterate over strings. The solution I found was inspired in the functions to explode and implode strings . These functions use the string indices to explode the string, creating a char list, or implode a char list, creating a string....

March 26, 2017 路 2 min

List Replication

Hi there! The idea of this problem is just to read some numbers from stdin and replicate them, but using lists. The input would be like this: 3 // # of repetitions 1 // first number ... 2 3 4 // end of input, last number Then the output would be a list with each number repeated the amount of times given. For the case above, it would show 鈥1鈥 three times, 鈥2鈥 three times and so on, each element on a different line....

March 24, 2017 路 2 min

Hello World printing in OCaml

Another simple problem from HackerRank is to print Hello World multiple times in a functional language. Well, I am using OCaml and I suppose I should avoid loops. The way I solved it is the following: open Core.Std let n = read_int ();; let rec print_hello n = if n > 0 then begin printf "Hello World\n"; print_hello (n-1); end else ();; print_hello n Problems I had: I lost some some time to discover the ;; was required to make it compile properly....

March 24, 2017 路 1 min

Compare Triplets in OCaml

Hi there! It has been a while since I played with OCaml, so I am solving a simple problem from HackerRank. The problem says the following 鈥淎lice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty鈥. For each category, we must check who had a greater score and give a point to that person for each category....

March 24, 2017 路 3 min

30 days of code in Go: Day 24 - Djikstra's algorithm

Hi there! Today I implemented Djikstra鈥檚 algorithm to find the minimum path between one source vertex and all the other vertices in the graph. This algorithm was devised in 1956 by the Dutch computer scientist Edsger W. Djikstra. It is quite fast having a complexity of $O(n\log n)$ when implemented with an auxiliary heap structure. To implement the heap in Go, I made use of the package heap. The package website also has an example of how to use and mine is basically a copy of it....

November 6, 2016 路 4 min