AJBM Posted April 8, 2017 at 08:10 AM Report #603533 Posted April 8, 2017 at 08:10 AM Boas, Eu tenho de fazer uma função em Scala que retorne uma lista com a junção de strings de listas diferentes. Ex: doStuff(List("ACE"), List("BDF")) Retorna ABCDEF Eu tenho isto, def doStuff(l: List[String],l2: List[String]): List[String] = { val newList:List[String]=List() if(l.size> l2.size) { for((elem,i)<- l.view.zipWithIndex) { if(i< l2.size) { for((x,j) <- elem.view.zipWithIndex) { if(j<l2(i).length()) { print( x.toChar +""+ l2(i).charAt(j)) } } println() } } } else { for((elem,i)<- l2.view.zipWithIndex){ if(i< l2.size){ for((x,j) <- elem.view.zipWithIndex) { if(j<l2(i).length()){ print(+l2(i).charAt(j)+ "" +x.toChar) } } println() } } } newList } O resultado do print está correto, mas eu precisava de retornar uma lista com esse valor. Não posso usar var. Alguém tem alguma dica? Obrigado
HappyHippyHippo Posted April 8, 2017 at 08:59 AM Report #603534 Posted April 8, 2017 at 08:59 AM que linguagem é essa ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now