Commits

Anonymous committed 41212d7

자바스런 읽고 말하기 수열을 조금 스칼라 스럽게 수정

  • Participants
  • Parent commits a081202

Comments (0)

Files changed (1)

File src/scala/_homework/arawn/AntSeq.scala

-def antSeq(value:String):String = {
+/* def antSeq(value:String):String = {
   var count = 0
   var temp = ""
   value.foreach( chr => {
 	}
   })
   count.toString + value(0) + temp
+} */
+
+def antSeq(value:String):String = {
+  val temp = value.dropWhile( _ equals value(0) )
+  temp.isEmpty match {
+    case true => value.length.toString + value(0)
+	case _ => (value.length - temp.length).toString + value(0) + antSeq(temp)
+  }
 }
 
 println("1 : " + antSeq("1"))