home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-07-30 | 742 b | 30 lines |
- // Copyright(c) 1996,1997 ObjectSpace, Inc.
-
- import COM.objectspace.jgl.*;
-
- /**
- * Applying a unary function to every element of a sequence.
- *
- * @see COM.objectspace.jgl.Applying
- * @version 2.0.2
- * @author ObjectSpace, Inc.
- */
-
- public class Applying1
- {
- public static void main( String[] args )
- {
- Array array = new Array();
- array.add( "cat" );
- array.add( "dog" );
- array.add( "emu" );
- System.out.println( "array = " + array );
-
- System.out.println( "Print each element to standard output" );
- Applying.forEach( array.begin(), array.end(), new Print() );
-
- System.out.println( "Print each element to standard output" );
- Applying.forEach( array, new Print() );
- }
- }
-