I was thinking about how to go about currying a method with varargs, and I realized that I don’t even have an intuition for how one would go about doing it. Ideally, it would be something that would let you start using it whenever you liked, and then end it with an iterable.
def concat(strs: String*) = strs.mkString
val curriedConcat = concat.curry
curriedConcat("OK")("hello", "world")("welcome")(Seq(): _*)
Is there support for this in scala? I couldn’t figure out how to do anything more than bind it to a function of length N and then curry that.
Using Scala 2.10 and shapeless:
Usage:
Without shapeless: