Not just a function : Generating functions

Every now and then, you hit some problem that a programming language helps solve very cleanly. Here’s the problem. You are writing a series of functions that return a bool depending on some condition (predicates). Something like bool Foo(State t); Let’s also assume that State is defined as class State  { Color c; … } You have a set of colors, known at compile time, for which Foo should return true. How would you go about doing it? You could pack the set of colors into an array and write Foo so that at runtime, it searches the color array … Continue reading Not just a function : Generating functions