1. trikitrok
  2. QuackExampleInScheme


Scheme code that does the same that a Strategy Pattern example in C++ I wrote recently.

I used DrRacket to test it in the REPL.

It's curious, I wonder if, after all, the need for a pattern like strategy in languages like Java or C++ arises from functions not being first-class citizens.

The Strategy pattern in C++ and Java would be a way to compose behavior as you do using higher order functions in Scheme.

I think it's a bit more, though, because a given strategy could also hold some state that might modify its behaviour...