11/* __ *\
22** ________ ___ / / ___ Scala API **
3- ** / __/ __// _ | / / / _ | (c) 2002-2013 , LAMP/EPFL **
3+ ** / __/ __// _ | / / / _ | (c) 2002-2016 , LAMP/EPFL **
44** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
55** /____/\___/_/ |_/____/_/ | | **
66** |/ **
77\* */
88
9- import scala .language .postfixOps
10-
119/** This program generates the ProductN, TupleN, FunctionN,
12- * and AbstractFunctionN, where 0 <= N <= MAX_ARITY .
10+ * and AbstractFunctionN, where 0 <= N <= MaxArity .
1311 *
1412 * Usage: scala genprod <directory>
1513 * where the argument is the desired output directory
1614 *
1715 * @author Burak Emir, Stephane Micheloud, Geoffrey Washburn, Paul Phillips
1816 */
1917object genprod extends App {
20- val MAX_ARITY = 22
21- def arities = (1 to MAX_ARITY ).toList
18+ final val MaxArity = 22
19+ def arities = (1 to MaxArity ).toList
2220
2321 class Group (val name : String ) {
2422 def className (i : Int ) = name + i
@@ -220,7 +218,7 @@ class Function(val i: Int) extends Group("Function") with Arity {
220218""" /** Creates a curried version of this function.
221219 *
222220 * @return a function `f` such that `f%s == apply%s`
223- */""" .format(xdefs map (" (" + _ + " )" ) mkString, commaXs)
221+ */""" .format(xdefs. map(" (" + _ + " )" ). mkString, commaXs)
224222 }
225223
226224 def tupleMethod = {
@@ -299,7 +297,7 @@ class Tuple(val i: Int) extends Group("Tuple") with Arity {
299297 // prettifies it a little if it's overlong
300298 def mkToString () = {
301299 def str (xs : List [String ]) = xs.mkString(""" + "," + """ )
302- if (i <= MAX_ARITY / 2 ) str(mdefs)
300+ if (i <= MaxArity / 2 ) str(mdefs)
303301 else {
304302 val s1 = str(mdefs take (i / 2 ))
305303 val s2 = str(mdefs drop (i / 2 ))
@@ -363,7 +361,7 @@ class Product(val i: Int) extends Group("Product") with Arity {
363361 def cases = {
364362 val xs = for ((x, i) <- mdefs.zipWithIndex) yield " case %d => %s" .format(i, x)
365363 val default = " case _ => throw new IndexOutOfBoundsException(n.toString())"
366- " \n " + ((xs ::: List (default)) map (" " + _ + " \n " ) mkString)
364+ " \n " + ((xs ::: List (default)). map(" " + _ + " \n " ). mkString)
367365 }
368366 def proj = {
369367 (mdefs,targs).zipped.map( (_,_) ).zipWithIndex.map { case ((method,typeName),index) =>
@@ -372,7 +370,7 @@ class Product(val i: Int) extends Group("Product") with Arity {
372370 | */
373371 | def %s: %s
374372 |""" .stripMargin.format(index + 1 , index + 1 , method, typeName)
375- } mkString
373+ }. mkString
376374 }
377375
378376 def apply () = {
0 commit comments