Busy. Please wait.
Log in with Clever
or

show password
Forgot Password?

Don't have an account?  Sign up 
Sign up using Clever
or

Username is available taken
show password


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
Your email address is only used to allow you to reset your password. See our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.

Programando Scala

Quiz yourself by thinking what should be in each of the black spaces below before clicking on it to display the answer.
        Help!  

Conceito
Exemplo
Para declarar um Iterator, basta igualar uma variável a instancia Iterator.   var it = Iterator(0, 1, 2, 3)  
🗑
Para percorrer uma lista utilizando Itarators, hasNext e Next basta montar uma estrutura de repetição While.   while (it.hasNext) println(it.Next())  
🗑
Para percorrer um Lista utilizando Iterators e foreach, basta declarar o foreach junto da ação.   it foreach println  
🗑
Para mostrar o próximo item da lista basta utilizar println com o next.   println(it.netx)  
🗑
Para verificar se existe um próximo elemento na lista basta utilizar o hasNext   it.hasNext  
🗑
Para fazer todos os numeros de 1 a 100 elevados ao quadrado basta usar um Itarator com uma range e um while para com o next para percorre-lo.   var it: Iterator[Int]=Iterator.range(1, 100) while(it.hasNext) { val x = it.next println(x * x) }  
🗑
Para declararmos um Stream somente de leitura, basta declarar um val com uma lista Stream.   val leitura = "Primeiro" #:: "Segundo" #:: "Terceiro" #:: Stream.empty  
🗑
Para declarar um Stream variável, basta declarar um var com uma lista Stream.   var listStream = 1 #:: 2 #:: Stream.empty  
🗑
Para inserir uma cadeia de valores em uma lista Stream basta utilizar uma range.   var s : Stream[Int] = Stream.range(1, 100)  
🗑
Para imprimir qualquer valor dentro do stream basta passar seu índice como parâmetro.   var s = 167 #:: 10 #:: 0 #:: Stream.empty println(s(2)) // out: 0  
🗑
Condição if, se a expressão for verdade o bloco de código dentro do if será executado, se não, será executado o conjunto de código dentro do else.   if(x<20) { println("Verdadeiro"); } else{ println("Falso"); }  
🗑
Condição while. O ciclo repete enquanto a condição é verdadeira e se encerra quando a condição se torna falsa.   while(a<14) { println("O valor e:" +a); a = a + 1; }  
🗑
Condição do..while. O ciclo será executado uma vez antes do teste. Se a condição for verdadeira, o ciclo será repetido até que a condição dada se torne falsa.   do{ println("Valor e:" + a); a = a + 1; }while(a < 14)  
🗑
Condição for. O ciclo será executado até que a condição do intervalo i até j seja concluída.   for(a <- 1 to 4) { println("Valor e:" + a); }  
🗑
Para declarar funções deve-se utilizar def antes do nome da função e definir a lista de parâmetros e o tipo de retorno.   def functionName (a: Int, b: Int):Int = { function body return [expr] }  
🗑
Função que não retorna nada, pode retornar Unit (Void em Java), indica que a função não tem retorno, também é chamada de procedimento.   def printMe( ):Unit = { println("Ola, Scala!") }  
🗑
Declaração de classes em scala permite utilizar parâmetros.   class Complex(real: Double, imaginary: Double) { def re() = real; def im() = imaginary; }  
🗑
Em função chamada usando uma instância do objeto deve usar a notação de ponto.   [exemplo]. functionName (a: Int, b: Int)  
🗑
Para chamar funções basta definir qual função será chamada e quais os parâmetros serão enviados.   functionName (a,b)  
🗑
Para declarar variáveis deve-se utilizar val.   val a = 10;  
🗑


   

Review the information in the table. When you are ready to quiz yourself you can hide individual columns or the entire table. Then you can click on the empty cells to reveal the answer. Try to recall what will be displayed before clicking the empty cell.
 
To hide a column, click on the column name.
 
To hide the entire table, click on the "Hide All" button.
 
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
 
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.

 
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how
Created by: paradigmas
Popular Computers sets