From c1f27b70c6204f1fde94a49426e05ef19315b460 Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 19 Feb 2008 17:56:36 +0000 Subject: anonfuns now accept up to 22 args --- src/build/genprod.scala | 46 +++++++++++++++++--------------------- src/library/scala/Function10.scala | 26 +++++++++++++++++++++ src/library/scala/Function11.scala | 26 +++++++++++++++++++++ src/library/scala/Function12.scala | 26 +++++++++++++++++++++ src/library/scala/Function13.scala | 26 +++++++++++++++++++++ src/library/scala/Function14.scala | 26 +++++++++++++++++++++ src/library/scala/Function15.scala | 26 +++++++++++++++++++++ src/library/scala/Function16.scala | 26 +++++++++++++++++++++ src/library/scala/Function17.scala | 26 +++++++++++++++++++++ src/library/scala/Function18.scala | 26 +++++++++++++++++++++ src/library/scala/Function19.scala | 26 +++++++++++++++++++++ src/library/scala/Function20.scala | 26 +++++++++++++++++++++ src/library/scala/Function21.scala | 26 +++++++++++++++++++++ src/library/scala/Function22.scala | 26 +++++++++++++++++++++ 14 files changed, 359 insertions(+), 25 deletions(-) create mode 100644 src/library/scala/Function10.scala create mode 100644 src/library/scala/Function11.scala create mode 100644 src/library/scala/Function12.scala create mode 100644 src/library/scala/Function13.scala create mode 100644 src/library/scala/Function14.scala create mode 100644 src/library/scala/Function15.scala create mode 100644 src/library/scala/Function16.scala create mode 100644 src/library/scala/Function17.scala create mode 100644 src/library/scala/Function18.scala create mode 100644 src/library/scala/Function19.scala create mode 100644 src/library/scala/Function20.scala create mode 100644 src/library/scala/Function21.scala create mode 100644 src/library/scala/Function22.scala (limited to 'src') diff --git a/src/build/genprod.scala b/src/build/genprod.scala index 0fd71ab95d..f7643e9968 100644 --- a/src/build/genprod.scala +++ b/src/build/genprod.scala @@ -17,16 +17,15 @@ * where PATH is the desired output directory *

* - * @author Burak Emir - * @version 1.0 + * @author Burak Emir, Stephane Micheloud + * @version 1.1 */ object genprod { /** The biggest ?? has Sup?? - 1 components/arguments */ val SUP_PRODUCT_ARITY = 23 val SUP_TUPLE_ARITY = 23 - val SUP_FUNCTION_ARITY = 9 - val SUP_CHOICE_ARITY = 9 // not implemented yet + val SUP_FUNCTION_ARITY = 23 def productClassname(i: Int) = "Product"+i @@ -59,9 +58,8 @@ object genprod { def mdefs(i: Int) = for (j <- List.range(1, i+1)) yield "_" + j - - def zippedAndCommaSeparated (left: List[String], right: List[String]): String = { - val sb = new StringBuffer() + def zippedAndCommaSeparated(left: List[String], right: List[String]): String = { + val sb = new StringBuilder val it = (left zip right).elements def append1 = { val p = it.next @@ -87,16 +85,13 @@ object genprod { def functionFiles = for (i <- List.range(0, SUP_FUNCTION_ARITY)) yield FunctionFile.make(i) - //def choiceFiles = - // for (i <- List.range(2, SUP_CHOICE_ARITY)) yield ChoiceFile.make(i) - def allfiles = productFiles ::: tupleFiles ::: functionFiles - def main(args:Array[String]) = { + def main(args: Array[String]) { if (args.length != 1) { - Console.println("please give path of output directory") - System.exit(-1) + println("please give path of output directory") + exit(-1) } import java.io.{File, FileOutputStream} import java.nio.channels.Channels @@ -112,8 +107,8 @@ object genprod { w.close } catch { case e: java.io.IOException => - Console.println(e.getMessage() + ": " + out) - System.exit(-1) + println(e.getMessage() + ": " + out) + exit(-1) } } } @@ -131,7 +126,7 @@ object FunctionFile { /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -184,8 +179,8 @@ trait {functionClassname(i)}{__typeArgs__} extends AnyRef {{ * def apply(): Long = System.currentTimeMillis() / 1000L * } * - * Console.println(currentSeconds()) - * Console.println(anonfun0()) + * println(currentSeconds()) + * println(anonfun0()) * }""" case 1 => """

In the following example the definition of @@ -201,8 +196,8 @@ trait {functionClassname(i)}{__typeArgs__} extends AnyRef {{ * def apply(x: Int): Int = x + 1 * } * - * Console.println(succ(0)) - * Console.println(anonfun1(0)) + * println(succ(0)) + * println(anonfun1(0)) * }""" case 2 => """

In the following example the definition of @@ -218,8 +213,8 @@ trait {functionClassname(i)}{__typeArgs__} extends AnyRef {{ * def apply(x: Int, y: Int): Int = if (x < y) y else x * } * - * Console.println(max(0, 1)) - * Console.println(anonfun2(0, 1)) + * println(max(0, 1)) + * println(anonfun2(0, 1)) * }""" case _ => "" } @@ -259,7 +254,7 @@ case class {tupleClassname(i)}{__typeArgs__}({ __fields__ }) { if ({i} == 1) "sb.append('(').append(_" + {i} + ").append(\",)\")" else { - val xs = List.range(1, i+1).map(i => ".append(_" + i + ")") + val xs = (1 to i).map(i => ".append(_" + i + ")") xs.mkString("sb.append('(')", ".append(',')",".append(')')") } } @@ -321,12 +316,13 @@ trait {productClassname(i)}{__typeArgs__} extends Product {{ * @return same as _(n+1) * @throws IndexOutOfBoundsException */ + @throws(classOf[IndexOutOfBoundsException]) override def productElement(n: Int) = n match {{ - {for (Tuple2(m, j) <- mdefs(i).zip(List.range(0, i))) + {for ((m, j) <- mdefs(i).zip(List.range(0, i))) yield "case "+j+" => "+m+"\n "}case _ => throw new IndexOutOfBoundsException(n.toString()) }} - {for (Tuple2(m, t) <- mdefs(i) zip targs(i)) yield + {for ((m, t) <- mdefs(i) zip targs(i)) yield "/** projection of this product */\n def " + m + ": " + t + "\n\n" } }} diff --git a/src/library/scala/Function10.scala b/src/library/scala/Function10.scala new file mode 100644 index 0000000000..ade34675c4 --- /dev/null +++ b/src/library/scala/Function10.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 10 parameters. + *

+ * + */ +trait Function10[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10): R + override def toString() = "" + +} diff --git a/src/library/scala/Function11.scala b/src/library/scala/Function11.scala new file mode 100644 index 0000000000..b9dd8b3f88 --- /dev/null +++ b/src/library/scala/Function11.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 11 parameters. + *

+ * + */ +trait Function11[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10, v11:T11): R + override def toString() = "" + +} diff --git a/src/library/scala/Function12.scala b/src/library/scala/Function12.scala new file mode 100644 index 0000000000..f2af9f9ef2 --- /dev/null +++ b/src/library/scala/Function12.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 12 parameters. + *

+ * + */ +trait Function12[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10, v11:T11, v12:T12): R + override def toString() = "" + +} diff --git a/src/library/scala/Function13.scala b/src/library/scala/Function13.scala new file mode 100644 index 0000000000..89de7e4bc1 --- /dev/null +++ b/src/library/scala/Function13.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 13 parameters. + *

+ * + */ +trait Function13[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10, v11:T11, v12:T12, v13:T13): R + override def toString() = "" + +} diff --git a/src/library/scala/Function14.scala b/src/library/scala/Function14.scala new file mode 100644 index 0000000000..acfa750183 --- /dev/null +++ b/src/library/scala/Function14.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 14 parameters. + *

+ * + */ +trait Function14[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10, v11:T11, v12:T12, v13:T13, v14:T14): R + override def toString() = "" + +} diff --git a/src/library/scala/Function15.scala b/src/library/scala/Function15.scala new file mode 100644 index 0000000000..4b1daed906 --- /dev/null +++ b/src/library/scala/Function15.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 15 parameters. + *

+ * + */ +trait Function15[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10, v11:T11, v12:T12, v13:T13, v14:T14, v15:T15): R + override def toString() = "" + +} diff --git a/src/library/scala/Function16.scala b/src/library/scala/Function16.scala new file mode 100644 index 0000000000..e09499c767 --- /dev/null +++ b/src/library/scala/Function16.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 16 parameters. + *

+ * + */ +trait Function16[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10, v11:T11, v12:T12, v13:T13, v14:T14, v15:T15, v16:T16): R + override def toString() = "" + +} diff --git a/src/library/scala/Function17.scala b/src/library/scala/Function17.scala new file mode 100644 index 0000000000..83f9230024 --- /dev/null +++ b/src/library/scala/Function17.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 17 parameters. + *

+ * + */ +trait Function17[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10, v11:T11, v12:T12, v13:T13, v14:T14, v15:T15, v16:T16, v17:T17): R + override def toString() = "" + +} diff --git a/src/library/scala/Function18.scala b/src/library/scala/Function18.scala new file mode 100644 index 0000000000..6b798ed132 --- /dev/null +++ b/src/library/scala/Function18.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 18 parameters. + *

+ * + */ +trait Function18[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10, v11:T11, v12:T12, v13:T13, v14:T14, v15:T15, v16:T16, v17:T17, v18:T18): R + override def toString() = "" + +} diff --git a/src/library/scala/Function19.scala b/src/library/scala/Function19.scala new file mode 100644 index 0000000000..c3b27cc297 --- /dev/null +++ b/src/library/scala/Function19.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 19 parameters. + *

+ * + */ +trait Function19[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10, v11:T11, v12:T12, v13:T13, v14:T14, v15:T15, v16:T16, v17:T17, v18:T18, v19:T19): R + override def toString() = "" + +} diff --git a/src/library/scala/Function20.scala b/src/library/scala/Function20.scala new file mode 100644 index 0000000000..175c50edf1 --- /dev/null +++ b/src/library/scala/Function20.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 20 parameters. + *

+ * + */ +trait Function20[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10, v11:T11, v12:T12, v13:T13, v14:T14, v15:T15, v16:T16, v17:T17, v18:T18, v19:T19, v20:T20): R + override def toString() = "" + +} diff --git a/src/library/scala/Function21.scala b/src/library/scala/Function21.scala new file mode 100644 index 0000000000..5825699025 --- /dev/null +++ b/src/library/scala/Function21.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 21 parameters. + *

+ * + */ +trait Function21[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, -T21, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10, v11:T11, v12:T12, v13:T13, v14:T14, v15:T15, v16:T16, v17:T17, v18:T18, v19:T19, v20:T20, v21:T21): R + override def toString() = "" + +} diff --git a/src/library/scala/Function22.scala b/src/library/scala/Function22.scala new file mode 100644 index 0000000000..1dc29a0e81 --- /dev/null +++ b/src/library/scala/Function22.scala @@ -0,0 +1,26 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: genprod.scala 13898 2008-02-06 10:43:23Z michelou $ + +// generated by genprod on Tue Feb 19 17:26:58 CET 2008 + +package scala + + +/**

+ * Function with 22 parameters. + *

+ * + */ +trait Function22[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, -T21, -T22, +R] extends AnyRef { + def apply(v1:T1, v2:T2, v3:T3, v4:T4, v5:T5, v6:T6, v7:T7, v8:T8, v9:T9, v10:T10, v11:T11, v12:T12, v13:T13, v14:T14, v15:T15, v16:T16, v17:T17, v18:T18, v19:T19, v20:T20, v21:T21, v22:T22): R + override def toString() = "" + +} -- cgit v1.2.3