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.

Scala Language

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

Term
Definition
Técnica Partials com Currying Exemplo: Multiplica Elemento pela constante passada no partial.   def multip2(x : Int)(y : Int) = x * y; val m = multip2(2)(_Int) m(3) //Saida: 6  
🗑
Função Currying Exemplo: Função que recebe um inteiro e uma função que multiplica dois inteiros.   def multip(x : Int)(y : Int) = x * y; def faca(a : Int, f : Int => Int):Int = f(a); faca(5, multip(2)); //Saida: 10  
🗑
Função Anônima Exemplo: Se y verdadeiro exibe x, se falso exibe x*2   (x:Int, y:Boolean) => if(y) println(x) else println(x*2)  
🗑
Função Anônima (como função de primeira ordem). Exemplo: Soma elemento com o seu quadrado.   def soma(x:Int, f:Int => Int) = x + f(x); soma(5, (x: Int) => x*x); // Saida: 30  
🗑
Função Anônima: método infixo encadeado. Exemplo: Mapear um operador em uma faixa de 1 a 5   println((1 to 5).map(2*)); //Saida Vector(2,4,6,8,10)  
🗑
Construção de uma classe (Construtor Implícito nos argumentos) Exemplo: Classe aluno com função para imprimir os dados.   class Aluno(nome:String, nota:Int, aprovado:Boolean) { def imp = println(this.nota+","+"this.nome"+","+this.aprovado"); }  
🗑
Instancia de uma Classe. Exemplo: Construir objeto da classe Aluno   val al = new Aluno("Joao", 70, true); al.imp; // Saida: "Joao e 70 e true"  
🗑
Operadores como função. Exemplo: Multiplicar 2 por 3 e somar 5.   (2.*(3)).+(5) // Saida: 11  
🗑
Operações com lista (Head). Exemplo: Declarar lista com 5 números inteiros e exibir a cabeça da lista.   val lista = List(1,2,3,4,5); lista.head // Saida 1  
🗑
Operações com lista (Tail). Exemplo: Declarar lista com 5 numeros inteiros e exibir a calda.   val lista = List(1,2,3,4,5); lista.tail // Saida 2,3,4,5 scala> somaEntreComF(1, 10, x => x * x) res10: Int = 385  
🗑
Operações com lista(Foreach). Exemplo: Percorrer uma lista imprimindo seus elementos.   val lista = List(1,2,3,4,5); lista.foreach(x=>print("-"+x)); // Saida: -1-2-3-4-5  
🗑
Operações com lista (Concatenar). Exemplo: Declarar uma lista de 3 elementos inteiros e concatenar um inteiro.Simbolo de concatenação '::'   val lista = List(1,2,3); val listac = 0::lista; listac.foreach(x=>print(x));//Saida 0123  
🗑
Função Anônima: estilo ‘pipeline’. (ou também parênteses). Exemplo: Em uma faixa de 1 a 5, função os pares e multiplica por 2.   (1 to 5) filter {_%2 == 0} map {_*2} //Saida: 4 8  
🗑
Função Currying com Lista. Exemplo: Aplicar propriedade para cada elemento da Lista de notas, e retornar uma lista de notas aprovadas.   def LisAprov(x: List[Int], fa:Int=>Boolean):List[Int] = if(x.isEmpty)x; else if(fa(x.head)) x.head::LisAprov(x.tail, fa); else LisAprov(x.tail, fa); def Aprovados(media:Int)(nota:Int) = nota>=media;  
🗑
Definição Função Currying. Exemplo: Forma alternativa de declaração.   def fcur(nome:String)=(sobrenome:String)=>nome+sobrenome;  
🗑
Passagem de Parâmetro: Avaliação Aplicativa   def numero(x: Int, y: Int) = x def loop : Int = loop numero(5, loop); // Entra em loop infinito  
🗑
Passagem de Parâmetro: Avaliação Tardia   def numero(x: Int, y => Int) = x def loop : Int = loop numero(5, loop); // não avalia o segundo parametro, retorna o 5  
🗑
Função de ordem superior object Timer { def oncePerSecond(callback: () => unit){while (true){ callback(); Thread sleep 1000 }} def timeFlies() { println("o tempo corre como um raio...")} def main(args: Array[String]){ oncePerSecond(timeFlies)}}   Utilização de função anônima: object TimerAnonymous { def oncePerSecond(callback: () => unit) { while (true) { callback(); Thread sleep 1000 } } def main(args: Array[String]) { oncePerSecond(() => println("o tempo corre como um raio...")) } }  
🗑
   
🗑
   
🗑


   

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: MELLISSAPUC
Popular Languages sets