diff options
author | michelou <michelou@epfl.ch> | 2006-12-08 19:10:22 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2006-12-08 19:10:22 +0000 |
commit | 1e5fd9b56a92dc162ce28346b0a705e8940f58d9 (patch) | |
tree | a9d180c01e2c44bdc7bb7d8104881c523e45706d /src/build/genprod.scala | |
parent | cb3adcfb6d0023da523c6a9f04dc8b7b5555e85c (diff) | |
download | scala-1e5fd9b56a92dc162ce28346b0a705e8940f58d9.tar.gz scala-1e5fd9b56a92dc162ce28346b0a705e8940f58d9.tar.bz2 scala-1e5fd9b56a92dc162ce28346b0a705e8940f58d9.zip |
updated genprod.scala (Function1)
Diffstat (limited to 'src/build/genprod.scala')
-rw-r--r-- | src/build/genprod.scala | 89 |
1 files changed, 51 insertions, 38 deletions
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 - * <code>currentSeconds</code> is a shorthand for the anonymous class - * definition <code>anonfun0</code>: - * <pre> - * <b>object</b> Main <b>extends</b> Application { + case 0 => """<p> + In the following example the definition of + * <code>currentSeconds</code> is a shorthand for the anonymous class + * definition <code>anonfun0</code>: + * </p> + * <pre> + * <b>object</b> Main <b>extends</b> Application { * - * <b>val</b> currentSeconds = () => System.currentTimeMillis() / 1000L + * <b>val</b> currentSeconds = () => System.currentTimeMillis() / 1000L * - * <b>val</b> anonfun0 = <b>new</b> Function0[Long] { - * <b>def</b> apply(): Long = System.currentTimeMillis() / 1000L - * } + * <b>val</b> anonfun0 = <b>new</b> Function0[Long] { + * <b>def</b> apply(): Long = System.currentTimeMillis() / 1000L + * } * - * Console.println(currentSeconds()) - * Console.println(anonfun0()) - * }</pre>""" - case 1 => """In the following example the definition of - * <code>succ</code> is a shorthand for the anonymous class definition - * <code>anonfun1</code>: - * <pre> - * <b>object</b> Main <b>extends</b> Application { + * Console.println(currentSeconds()) + * Console.println(anonfun0()) + * }</pre>""" + case 1 => """<p> + In the following example the definition of + * <code>succ</code> is a shorthand for the anonymous class definition + * <code>anonfun1</code>: + * </p> + * <pre> + * <b>object</b> Main <b>extends</b> Application { * - * <b>val</b> succ = (x: Int) => x + 1 + * <b>val</b> succ = (x: Int) => x + 1 * - * <b>val</b> anonfun1 = <b>new</b> Function1[Int, Int] { - * <b>def</b> apply(x: Int): Int = x + 1 - * } + * <b>val</b> anonfun1 = <b>new</b> Function1[Int, Int] { + * <b>def</b> apply(x: Int): Int = x + 1 + * } * - * Console.println(succ(0)) - * Console.println(anonfun1(0)) - * }</pre>""" - case 2 => """In the following example the definition of - * <code>max</code> is a shorthand for the anonymous class definition - * <code>anonfun2</code>: - * <pre> - * <b>object</b> Main <b>extends</b> Application { + * Console.println(succ(0)) + * Console.println(anonfun1(0)) + * }</pre>""" + case 2 => """<p> + In the following example the definition of + * <code>max</code> is a shorthand for the anonymous class definition + * <code>anonfun2</code>: + * </p> + * <pre> + * <b>object</b> Main <b>extends</b> Application { * - * <b>val</b> max = (x: Int, y: Int) => <b>if</b> (x < y) y <b>else</b> x + * <b>val</b> max = (x: Int, y: Int) => <b>if</b> (x < y) y <b>else</b> x * - * <b>val</b> anonfun2 = <b>new</b> Function2[Int, Int, Int] { - * <b>def</b> apply(x: Int, y: Int): Int = <b>if</b> (x < y) y <b>else</b> x - * } + * <b>val</b> anonfun2 = <b>new</b> Function2[Int, Int, Int] { + * <b>def</b> apply(x: Int, y: Int): Int = <b>if</b> (x < y) y <b>else</b> x + * } * - * Console.println(max(0, 1)) - * Console.println(anonfun2(0, 1)) - * }</pre>""" + * Console.println(max(0, 1)) + * Console.println(anonfun2(0, 1)) + * }</pre>""" case _ => "" } |