16.8. Sling Functions

In the source code for the function classes in the SlingFunction hierarchy, the design principles show through. They are as follows:

  • Represent each known function with a class that implements the method f().

  • Write f() for each function class so that it wraps its function around other function objects. Require that these objects be supplied to the class constructor.

  • Define the signature of f() to be Point f(double t).

  • For any base function that would naturally return a single number y, return new Point(t, y), where t is the input parameter to f().

The classes in this hierarchy also provide the ability to create unvariable functions from variable functions by evaluating their sources. The Variable class and the hierarchy superclass ...

Get Building Parsers with Java™ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.