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.3. Sling Programming

This section shows how to program in Sling. Playing with Sling is fun. You can start the Sling IDE with

> java sjm.examples.sling.SlingIde 

16.3.1. A Basic Sling

Sling lets you plot mathematical functions by issuing plot commands. The namesake of Sling is the sling() function, which takes two arguments: the length of the sling strap, and the number of times the sling goes around (one's head). For example, to plot the path of a sling whose strap length is 1 and that travels three-quarters of a revolution, run the class SlingIde and enter the Sling program

plot sling(1, .75); 

Click the Go! button in the IDE or press the Ctrl and G keyboard keys to make the program execute. Figure 16.1 shows the results.

Figure 16.1. A ...

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