Last active
June 12, 2019 08:38
-
-
Save paulcarey/c33d1834f0395257ddbaea992c9a0fd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def f(s: String) = { | |
val xs = s.split("\n").map(_.split(",")) | |
val ys = xs.transpose.map(_.map(_.length).max) | |
val zs = xs.map(_.zip(ys)) | |
val ls = zs.map(_.map { case (x,y) => x.padTo(y, ' ') }.mkString(" ")) | |
ls.mkString("\n") | |
} | |
val s = """aaa,b,cc | |
|a,bbbbb,c""".stripMargin | |
f(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment