diff options
author | Geoffrey Washburn <geoffrey.washburn@epfl.ch> | 2008-04-22 14:37:50 +0000 |
---|---|---|
committer | Geoffrey Washburn <geoffrey.washburn@epfl.ch> | 2008-04-22 14:37:50 +0000 |
commit | eb6911e3aa5cdc733ebc2045934a8a2072060fc4 (patch) | |
tree | 2e07b97f9e768691e0494b66ec3fe450823feb84 /src/build | |
parent | 39f2357f9c861be97adb468ab6b4a323f6265afa (diff) | |
download | scala-eb6911e3aa5cdc733ebc2045934a8a2072060fc4.tar.gz scala-eb6911e3aa5cdc733ebc2045934a8a2072060fc4.tar.bz2 scala-eb6911e3aa5cdc733ebc2045934a8a2072060fc4.zip |
Corrected uncurry to be called curry.
Generalized curry to FunctionN for N >= 2
Diffstat (limited to 'src/build')
-rw-r--r-- | src/build/genprod.scala | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/build/genprod.scala b/src/build/genprod.scala index c0c6c9c00d..d00d223ddd 100644 --- a/src/build/genprod.scala +++ b/src/build/genprod.scala @@ -36,6 +36,11 @@ object genprod { def functionClassname(i: Int) = "Function"+i def functionFilename(i: Int) = functionClassname(i)+".scala" + def join(sep: String, xs: Seq[String]): String = + if (xs.length == 0) "" + else xs.drop(1).foldLeft(xs.first) { (acc, x) => acc + sep + x } + + def targs(i: Int) = for (j <- List.range(1, i+1)) yield "T" + j @@ -155,12 +160,15 @@ trait {functionClassname(i)}{__typeArgs__} extends AnyRef {{ */ def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) } """ - case 2 => """ - /** f(x,y) == (f.uncurry)(x)(y) + case _ if i > 1 => """ + /** f(""" + join(",", (1 to i).map(i => "x" + i)) + """) == (f.curry)""" + join("", (1 to i).map(i => "(x" + i + ")")) + """ */ - def uncurry: T1 => T2 => R = { (x:T1) => (y:T2) => apply(x,y) } + def curry: """ + join(" => ", (1 to i).map(i => "T" + i)) + """ => R = { """ + + join(" => ", (1 to i).map(i => "(x" + i + ": T" + i + ")")) + """ => apply(""" + join(",", (1 to i).map(i => "x" + i)) + """) } """ - case _ => "" + case _ => """ +""" + } def descriptiveComment(i: Int) = i match { case 0 => """<p> |