Thursday, November 13, 2014

Caesar Cipher in Haskell

Detecting balanced Parentheses in Advanced Student Language

Today I revisited this exercise from the Coursera Scala course that I did some time ago using the Advanced Student Language:

I refactored it to define the helper function f inside balanced-parentheses?.

Since it is not allowed to have nested function definitions in Advanced Student Language (it's in Racket), I defined the function using letrec and a lambda.

I had forgotten how many parentheses a cond needs in Advanced Student Language. In that sense Clojure is far more convenient.

Revisited Kata: Berlin Clock in Clojure

I've revisited the code of the Berlin Clock kata that I did sometime ago in Clojure to apply on it some of the things that I've learned lately.

This is my original solution:

and this is the new one:

Wednesday, November 12, 2014

Euler Project: Problem 2 in Haskell

This is my solution in Haskell to the second problem:


I still get a bit dizzy when I think about the second solution...

You will find a great explanation of the second solution in this post:
Fibonacci numbers: the slow way or the fast and lazy way

You'll find the solutions in Haskell to Project Euler problems that I've done so far in this GitHub repository.

Kata: FizzBuzz in SML

This is the code of the FizzBuzz kata in SML that I did some time ago using pattern matching and refactored this morning to use List's map and tabulate functions:


You can check the code in this Bitbucket repository.