# Monthly Archives: April 2011

## Side effects for fun and profit

Consider this infinite Fibonacci sequence:       var fib = fcn(ab){a,b:=ab; ab.del(0)+(a+b); a}.fp(L(0,1)); Ask it for a Fibonacci number and you get the first one. Ask again and you get the next one and so on:       > do(15){print(fib(),”,”)} → 0,1,1,2,3,5,8,13,21,34,55,89,144,233,377It never restarts, … Continue reading

## Side effects – Don’t leave home without them

For me, one of the coolest things about functional programming languages is using [arglist] pattern matching and recursion to concisely express an algorithm. However, there are other ways to juice the pomegranate. I was staring at the Pure code for … Continue reading

## Symmetry Symmetry

I was implementing the [un]zip family of functions (from Haskel, see List functions) and noticed this lovely symmetry: unzip(unzip(a)) –> a One element lists:listUnzip(L(L(1,2,3,4,5,6,7,8,9,0))) –> L(L(1),L(2),L(3),L(4),L(5),L(6),L(7),L(8),L(9),L(0))listUnzip(L(L(1),L(2),L(3),L(4),L(5),L(6),L(7),L(8),L(9),L(0))) –> L(L(1,2,3,4,5,6,7,8,9,0)) Pairs:listUnzip(L( L(1,2), L(3,4), L(5,6), L(7,8), L(9,0))) –> L( L(1,3,5,7,9), L(2,4,6,8,0))listUnzip(L( L(1,3,5,7,9), L(2,4,6,8,0))) … Continue reading