summaryrefslogtreecommitdiff
path: root/src/library/scala/Function1.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-02-20 06:51:57 +0000
committerPaul Phillips <paulp@improving.org>2011-02-20 06:51:57 +0000
commitfd1ca1e63c876046936f681be26730a301da8ff2 (patch)
tree6db9fac72b958af0df8c51eeae8478c0fe5b6a98 /src/library/scala/Function1.scala
parent6a570deed1790889f7036a00c045c15217313587 (diff)
downloadscala-fd1ca1e63c876046936f681be26730a301da8ff2.tar.gz
scala-fd1ca1e63c876046936f681be26730a301da8ff2.tar.bz2
scala-fd1ca1e63c876046936f681be26730a301da8ff2.zip
Moved unlift to the Function companion object, ...
Moved unlift to the Function companion object, which might have been better in the first place. Had to make a minor change to genprod, and then I couldn't escape that unscathed. Finished the not very complete undertaking I found there to update the scaladoc. Lots of little changes to the generated text and code. I changed genprod to only put a unique stamp on Function0 so we can stop having a 100 file diff everytime an i is dotted somewhere. Closes #3825, no review.
Diffstat (limited to 'src/library/scala/Function1.scala')
-rw-r--r--src/library/scala/Function1.scala52
1 files changed, 20 insertions, 32 deletions
diff --git a/src/library/scala/Function1.scala b/src/library/scala/Function1.scala
index 8fb50b49b5..e256a94961 100644
--- a/src/library/scala/Function1.scala
+++ b/src/library/scala/Function1.scala
@@ -5,59 +5,47 @@
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-
-// generated by genprod on Sat Oct 16 11:19:09 PDT 2010 (with fancy comment) (with extra methods)
+// GENERATED CODE: DO NOT EDIT. See scala.Function0 for timestamp.
package scala
-
-
-/** Function with 1 parameter.
+/** A function of 1 parameter.
*
- * In the following example the definition of
- * succ is a shorthand for the anonymous class
- * definition anonfun1:
+ * 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 anonfun1 = new Function1[Int, Int] {
* def apply(x: Int): Int = x + 1
* }
- *
- * println(succ(0))
- * println(anonfun1(0))
+ * assert(succ(0) == anonfun1(0))
* }
* }}}
*/
trait Function1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double) +R] extends AnyRef { self =>
- def apply(v1:T1): R
- override def toString() = "<function1>"
-
- /** (f compose g)(x) == f(g(x))
+ /** Apply the body of this function to the argument.
+ * @return the result of function application.
*/
- def compose[A](g: A => T1): A => R = { x => apply(g(x)) }
+ def apply(v1: T1): R
- /** (f andThen g)(x) == g(f(x))
+ /** Composes two instances of Function1 in a new Function1, with this function applied last.
+ *
+ * @tparam A the type to which function `g` can be applied
+ * @param g a function A => T1
+ * @return a new function `f` such that `f(x) == apply(g(x))`
*/
- def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) }
+ def compose[A](g: A => T1): A => R = { x => apply(g(x)) }
- /** Turns a function A => Option[B] into a PartialFunction[A, B]. Important note:
- * this transformation implies the original function will be called 2 or more
- * times on each logical invocation, because the only way to supply an implementation
- * of isDefinedAt is to call the function and examine the return value.
+ /** Composes two instances of Function1 in a new Function1, with this function applied first.
*
- * @see PartialFunction#lift
- * @return a partial function which is defined for those inputs
- * where this function returns Some(_) and undefined where
- * this function returns None.
+ * @tparam A the result type of function `g`
+ * @param g a function R => A
+ * @return a new function `f` such that `f(x) == g(apply(x))`
*/
- def unlift[R1](implicit ev: R <:< Option[R1]): PartialFunction[T1, R1] = new PartialFunction[T1, R1] {
- def apply(x: T1): R1 = ev(Function1.this.apply(x)).get
- def isDefinedAt(x: T1): Boolean = Function1.this.apply(x).isDefined
- override def lift = Function1.this.asInstanceOf[T1 => Option[R1]]
- }
+ def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) }
+ override def toString() = "<function1>"
}