From 1e5fd9b56a92dc162ce28346b0a705e8940f58d9 Mon Sep 17 00:00:00 2001 From: michelou Date: Fri, 8 Dec 2006 19:10:22 +0000 Subject: updated genprod.scala (Function1) --- src/build/genprod.scala | 89 ++++++++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 38 deletions(-) (limited to 'src/build') diff --git a/src/build/genprod.scala b/src/build/genprod.scala index c0ca4df0d8..ad38418e1b 100644 --- a/src/build/genprod.scala +++ b/src/build/genprod.scala @@ -129,8 +129,10 @@ object FunctionFile { package scala -/** - * Function with {i} parameters. {descriptiveComment(i)} +/** <p> + * Function with {i} parameters. + * </p> + * {descriptiveComment(i)} */ trait {functionClassname(i)}{__typeArgs__} extends AnyRef {{ def apply({__funArgs__}): R @@ -142,57 +144,68 @@ trait {functionClassname(i)}{__typeArgs__} extends AnyRef {{ def moreMethods(i:Int) = i match { case 1 => """ + /** (f compose g)(x) = f(g(x)) + */ def compose[A](g: A => T1): A => R = { x => apply(g(x)) } + + /** (f andThen g)(x) = g(f(x)) + */ def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) } """ case _ => "" } def descriptiveComment(i: Int) = i match { - case 0 => """In the following example the definition of - * currentSeconds is a shorthand for the anonymous class - * definition anonfun0: - *
- * object Main extends Application {
+    case 0 => """

+ In the following example the definition of + * currentSeconds is a shorthand for the anonymous class + * definition anonfun0: + *

+ *
+ *  object Main extends Application {
  *
- *   val currentSeconds = () => System.currentTimeMillis() / 1000L
+ *    val currentSeconds = () => System.currentTimeMillis() / 1000L
  *
- *   val anonfun0 = new Function0[Long] {
- *     def apply(): Long = System.currentTimeMillis() / 1000L
- *   }
+ *    val anonfun0 = new Function0[Long] {
+ *      def apply(): Long = System.currentTimeMillis() / 1000L
+ *    }
  *
- *   Console.println(currentSeconds())
- *   Console.println(anonfun0())
- * }
""" - case 1 => """In the following example the definition of - * succ is a shorthand for the anonymous class definition - * anonfun1: - *
- * object Main extends Application {
+ *    Console.println(currentSeconds())
+ *    Console.println(anonfun0())
+ *  }
""" + case 1 => """

+ In the following example the definition of + * succ is a shorthand for the anonymous class definition + * anonfun1: + *

+ *
+ *  object Main extends Application {
  *
- *   val succ = (x: Int) => x + 1
+ *    val succ = (x: Int) => x + 1
  *
- *   val anonfun1 = new Function1[Int, Int] {
- *     def apply(x: Int): Int = x + 1
- *   }
+ *    val anonfun1 = new Function1[Int, Int] {
+ *      def apply(x: Int): Int = x + 1
+ *    }
  *
- *   Console.println(succ(0))
- *   Console.println(anonfun1(0))
- * }
""" - case 2 => """In the following example the definition of - * max is a shorthand for the anonymous class definition - * anonfun2: - *
- * object Main extends Application {
+ *    Console.println(succ(0))
+ *    Console.println(anonfun1(0))
+ *  }
""" + case 2 => """

+ In the following example the definition of + * max is a shorthand for the anonymous class definition + * anonfun2: + *

+ *
+ *  object Main extends Application {
  *
- *   val max = (x: Int, y: Int) => if (x < y) y else x
+ *    val max = (x: Int, y: Int) => if (x < y) y else x
  *
- *   val anonfun2 = new Function2[Int, Int, Int] {
- *     def apply(x: Int, y: Int): Int = if (x < y) y else x
- *   }
+ *    val anonfun2 = new Function2[Int, Int, Int] {
+ *      def apply(x: Int, y: Int): Int = if (x < y) y else x
+ *    }
  *
- *   Console.println(max(0, 1))
- *   Console.println(anonfun2(0, 1))
- * }
""" + * Console.println(max(0, 1)) + * Console.println(anonfun2(0, 1)) + * }
""" case _ => "" } -- cgit v1.2.3