web developer & system programmer

coder . cl

ramblings and thoughts on programming...


challenge 2012.02.13 intermediate

published: 14-02-2012 / updated: 14-02-2012
posted in: development, haskell, programming, tips
by Daniel Molina Wegener

Here is the another combinatorics challenge with a level intermediate on the programming forum. Still I think that they are very easy to solve. Here is the solution in Haskell, where not real combinatorics are required to supply a solution, instead word elements are used as numbers to find word matches in the text file, without too many libraries and lines of code.

combinatorics problem in haskell

published: 12-02-2012 / updated: 12-02-2012
posted in: development, haskell, programming, tips
by Daniel Molina Wegener

Here is another challenge called difficult, but seems to be quite easy to solve. It is a simple feasible operation search algorithm between lists of numbers, so it is not so complex to solve and took few minutes to get it working on Haskell, because Haskell provides various tools to work with algorithms. Also this solution does the extra credit, no matter if the list has up to four integers.

small programming exercise

published: 10-02-2012 / updated: 10-02-2012
posted in: development, haskell, programming, tips
by Daniel Molina Wegener

On a programming forum I have found a small programming problem about guessing numbers. I have implemented its solutions this morning using Haskell, only to practice a little some Haskell programming. The problem is quite easy to solve. I have used lists instead of arithmetic operations to reach the final number without errors, avoiding user mistakes.

understanding mapreduce

published: 04-02-2012 / updated: 21-04-2012
posted in: development, haskell, programming, tips
by Daniel Molina Wegener

MapReduce is a distributed computing model introduced by Google with its framework for distributed computing called MapReduce. Its conceptual basis comes from a functional programming approach based mainly on the basic mathematical concept of Monoid treatment in functional programming. Basically a Monoid lifts data using map and process that data using fold — which is called reduce in Python, returning the same bound type as its input — and can be expressed as the triple \langle A, \varepsilon, \cdot \rangle as the set A, the neutral element \varepsilon and the operation \cdot. The problem with the Monoid definition is the fact that it is bound to a type, where MapReduce is not bound to any type, and even it is not bound to a Category.

programming practice 1991-c, part 2

published: 01-01-2012 / updated: 01-01-2012
posted in: development, haskell, programming, tips
by Daniel Molina Wegener

As you know I am learning Haskell and doing small exercises based on the ACM ICPC problem archive. I am using those problem sets as my Haskell practice. The task presented on the problem 1991-c is related to a small DSL which handles concurrency simulations, using two simple instruction called lock and unlock to switch between running and ready states. The DSL defined for this problem seems to be simple. I have used the Parsec Haskell package to build the language parser. Where on my last post about this problem I have created the program parser, and now I build the interpreter.

jquery is not a monad

published: 19-12-2011 / updated: 19-12-2011
posted in: development, haskell, programming, tips
by Daniel Molina Wegener

There are some nice articles explaining that jQuery is a Monad, from the basis that jQuery chains computations with a returning type — with very simple words — but that is not enough to say that jQuery is a Monad. A Monad should meet certain conditions, from supplying support to its laws to defining the proper methods covering its monadic behaviour. So, it basically should supply support for the three Monad Laws, called associativity, right identity and left identity, where all of them are applied to the same type — or category from its Math background.

programming practice 1991-c, part 1

published: 03-12-2011 / updated: 03-12-2011
posted in: development, haskell, programming, tips
by Daniel Molina Wegener

As you know I am learning Haskell and doing small exercises based on the ACM ICPC problem archive. I am using those problem sets as my Haskell practice. The task presented on the problem 1999-c is related to a small DSL which handles concurrency simulations, using two simple instruction called lock and unlock to switch between running and ready states. The DSL defined for this problem seems to be simple. I have used the Parsec Haskell package to build the language parser.