Inicio > English > Hackwell in Haskell: a Haskell hackathon in StackBuilders

Hackwell in Haskell: a Haskell hackathon in StackBuilders

29 marzo, 2014
Presenting a solution for the snail kata.

Presenting a solution for the snail kata.

Today have taken place in the StackBuilders offices in Quito what seems to be the first Hackathon using a funcional language, in Ecuador. For this ocasion, we’ve been using Haskell.

Haskell is a functional programming language created in 1990 that takes its name from Haskell Curry, an american mathematician in which works about logics are partially based the current functional programming languages. Haskell is a strongly typed language, although it differs from other functional languages as Clojure in not forcing the data structures inmutability.

During the day, the problem proposed was solving the snail kata in Haskell. The snail kata consist in, given a squared matrix, return an array with all the matrix elements sorted as is shown in the following diagram:

 

We sort the matrix elements following an helix

We sort the matrix elements following an helix

 

So, for the next matrix:

array = [[1,2,3],
[4,5,6],
[7,8,9]]

the expected result of applying snail should be:

snail(array) #=> [1,2,3,6,9,8,7,4,5]

 

Speaking about the hackathon itself, I must say that it was really fun, that I’ve learned a lot, and that I’m very satisfied with the solution that my pair and me have developed, taking into account that it has been our first code in Haskell. There have been beer, pizza, and several funny moments🙂

About our solution, we’ve developed a first algorithm that:

  • Extracts the upper row.
  • Extracts the right column without the first element (which is already included in the upper row).
  • Concats the above with the result of calling again the function with the lower left submatrix, rotated 180 degrees.

After that, we have refined it to the following algorithm:

  • Extract all the matrix perimeter, concatenated in the correct order.
  • Concat the above with the result of calling again the function with the inner matrix (without the perimeter).

The solution is available in my Github account.

As pending tasks, I still need to learn how to test in Haskell. It has been quite an experience to program without tests after so much time applying TDD 100% of my time, and it has been like driving a car without safety belt. Also, I’ve confirmed again how much time is wasted when you lack automated tests.

 

Categorías:English Etiquetas: , ,
  1. 30 marzo, 2014 a las 14:54

    Reblogueó esto en Dormount’s Blogy comentado:
    Hackaton en Haskell, en StackBuilders

  1. No trackbacks yet.
Los comentarios están cerrados.
A %d blogueros les gusta esto: