Category Archives: Erlang
Learning to use foldl and map
I have been working on a small line drawing project, and part of that project is indexing nested lists based on sets of indices. Firstly I wrote a function to return the recursive nth item. So for this data [[[1,2],[3,4]],[[5,6],[7,8]]] … Continue reading
Memoizing with ETS
In my 3n + 1 post rickhg12hs suggested I use the erlang ets module to memoize my solution. To time the code before and after changes I found this little gem from David King -module(timer). -export([timer/3]). timer(Mod,Fun,Args) -> Start=erlang:now(), … Continue reading
The Trip – 110103 in Erlang
The third of my Programming Challenges solutions is for The Trip 110103 This problem is great for making you think. Key points are; you cannot have half cents, and you have to find the minimum money needed to balance costs … Continue reading
3n + 1 in Erlang
This is my second Programming Challenges solution written in Erlang. First here. This time I chose the first problem 3n + 1 #110101. It is a little bit of a cheat doing it in Erlang, as the major point of … Continue reading
Reverse And Add 110502 in Erlang
Carrying on from Cedric’s Challenge (C#, Erlang) I decided to do some of the Programming Challenges problems in Erlang, because the problems are small, but fun. My first is Reverse And Add #110502 and here is my solution: -module(revandadd). -export([rev_and_add/1, … Continue reading