summaryrefslogtreecommitdiff
path: root/test/files/pos/spec-Function1.scala
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2009-06-18 17:19:55 +0000
committerIulian Dragos <jaguarul@gmail.com>2009-06-18 17:19:55 +0000
commit3ee6b3653f8c25d7d6b19b9f5d4af7fa082146a8 (patch)
treee97b8c0dd8d61e82f825f528f98842f777621f7a /test/files/pos/spec-Function1.scala
parentbe8e3c69114da5bc3020d5363b338b1c83aa22ef (diff)
downloadscala-3ee6b3653f8c25d7d6b19b9f5d4af7fa082146a8.tar.gz
scala-3ee6b3653f8c25d7d6b19b9f5d4af7fa082146a8.tar.bz2
scala-3ee6b3653f8c25d7d6b19b9f5d4af7fa082146a8.zip
Specialization landed in trunk.
Diffstat (limited to 'test/files/pos/spec-Function1.scala')
-rw-r--r--test/files/pos/spec-Function1.scala50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/files/pos/spec-Function1.scala b/test/files/pos/spec-Function1.scala
new file mode 100644
index 0000000000..b749be0ba7
--- /dev/null
+++ b/test/files/pos/spec-Function1.scala
@@ -0,0 +1,50 @@
+
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id: Function1.scala 17163 2009-02-20 08:05:31Z dragos $
+
+// generated by genprod on Wed Apr 23 10:06:16 CEST 2008 (with fancy comment) (with extra methods)
+
+package scala
+
+
+/** <p>
+ * Function with 1 parameters.
+ * </p>
+ * <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> anonfun1 = <b>new</b> Function1[Int, Int] {
+ * <b>def</b> apply(x: Int): Int = x + 1
+ * }
+ *
+ * println(succ(0))
+ * println(anonfun1(0))
+ * }</pre>
+ */
+trait Function1[@specialized -T1, @specialized +R] extends AnyRef { self =>
+ def apply(v1:T1): R
+ override def toString() = "<function>"
+
+ /** (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)) }
+
+}