Avoiding late binding with trampolines

Consider the toBool method. Every object has one because everybody inherits from Object and Object has it. An object can override toBool to add its own functionality. Standard stuff. Also standard stuff in late bound languages is delaying resolution of … Continue reading

Composing compositions

A note on how I parse compositions (see previous–2 post). There are several ways to do this, I choose to post process the AST (Abstract Syntax Tree); I scan expressions for “:” and, if found, rewrite that node. Using the … Continue reading

99 bottles of … You gotta be kidding me

I was reading Lambda the Ultimate and someone posted they had a program accepted by http://99-bottles-of-beer.net/. My reaction: a combination of “please tell me you are joking” and WTF?. But it is for real, over 1,400 programs in different languages … Continue reading

Stream of Consciousness Programming

I’m something of a stream of consciousness programmer: I have a thing: fold, then spindle and finally mutilate it. Or: I want to do do this n times, so I’ll use a loop and do this stuff in it. And … Continue reading

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

Queen of the Races

The Queens N puzzle has lots of opportunity for parallelism so I thought I’d see what my dual core Windows system could do. Using the code from the previous post, pretty much what I’d expect: Two cores, two threads is … Continue reading