O'Reilly logo

Building Parsers with Java™ by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required