home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-09-13 | 1.3 KB | 33 lines |
- // Copyright(c) 1996 ObjectSpace, Inc.
-
- import jgl.*;
-
- /**
- * Applying - inject a container with a given binary function
- * which does a 'reduction' operation.
- * <p>
- * @see jgl.Applying
- * @version 1.1
- * @author ObjectSpace, Inc.
- */
-
- public class Applying2
- {
- public static void main( String[] args )
- {
- Array array = new Array();
- array.add( new Integer( 100 ) );
- array.add( new Integer( 2 ) );
- array.add( new Integer( 71 ) );
- System.out.println( "array = " + array );
- System.out.println( "injecting TimesInteger(initial value==1) = "
- + Applying.inject( array.begin(), array.end(),
- new Integer( 1 ), new TimesInteger() ) );
- System.out.println( "injecting PlusInteger(initial value==0) = "
- + Applying.inject( array, new Integer( 0 ), new PlusInteger() ) );
- System.out.println( "injecting MinusInteger(initial value==0) = "
- + Applying.inject( array, new Integer( 0 ), new MinusInteger() ) );
- System.out.println( "injecting DividesInteger(initial value==1000) = "
- + Applying.inject( array, new Integer( 100000 ), new DividesInteger() ) );
- }
- }