Busy. Please wait.
Log in with Clever

show password
Forgot Password?

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

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.
Didn't know it?
click below
Knew it?
click below
Don't Know
Remaining cards (0)
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


Linguagem de programação Scala

Scala é estaticamente tipada val x: Int = 99 val nome: String = "Jorge"
Scala possui inferência de tipos val x = 99 val nome = "Jorge"
Valores Imutáveis trata a variável como uma constante val nome = "jorge" a variável nome não pode ser mais alterada até que o programa termine.
Orientação a objetos Class Aluno(nome: String, matricula: Int) extends Pessoa(nome){ private var matriculaAluno = matricula def getMatriculaAluno = { this.matriculaAluno } def getNomeAluno = { super.gerNome() } }
Programação funcional object FiboFunctional extends App{ def fiboRec(x:Int):Int = { x match{ case 0|1 => x case _ => fiboRec(x-1) + fiboRec(x-2) } } println(fiboRec(10)) }
Em Scala tudo é um objeto object HelloWorld { def main(args: Array[String]) { println("Hello, world!") } }
Função de ordem superior def SomaEntr(a: Int, b: Int, f: Int =>Int):Int = { if(a > b) = 0 else f(a) + SomaEntre((a+1), b, f) } def quadrado(x: Int):Int = x*x println(SomaEntre(1, 10, quadrado))
Casamento Padrão def CasamentoPadrao(x:Any) = { x match{ case 1 => println("é um numero int") case 1.0 => println("é um double") case "dois" => println("é uma string") case true => println("é um bool") case _ => println("indefinido") } }
funções e valores val dez = 10 def vinte = dez * 2
Tuplas val tupla = ("um","dois","tres")
Acessando uma Tuplas tupla._3 //(retorna o terceiro item)
Tuplas de 2 ítens val alunosAprovados = Vector[(String,String)](("Mario Soares","MM"),("Janaina Paiva","SS"),("Johnny Souza","MS"))
exemplo de como acessar os dados de uma tupla val mencaoJanaina = alunosAprovados(1)._2
Acessando uma tupla através pattern matching alunosAprovados(2) match { case (nome, mencao) => println("Aluno " + nome + " obteve mencao " + mencao) } // (Aluno Johnny Souza obteve mencao MS)
recursividade de cauda def fatorial(num: Int):Int = { def fatorialIter(num: Int, acc: Int):Int = { if(num == 0) acc else fatorialIter(num - 1, acc * num) } fatorialIter(num, 1) }
@tailrec anotação que força uma função recursiva a ter recursividade de cauda def fatorial(num: Int): BigDecimal = { @tailrec def fatorialIter(num: Int, acc: BigDecimal): BigDecimal = { if (num == 0) acc else fatorialIter(num - 1, acc * num) } fatorialIter(num, 1) }
Lazy Evaluation def fibonacciSequence : Stream[Long] = { def fibonacciFrom(a: Long, b: Long) : Stream[Long] = a #:: fibonacciFrom(b, a+b) fibonacciFrom(0, 1) }
Traits trait Flyer { def fly = println("I can fly!") } class Animal { def breathe = println("Birds breath!") } class Bird extends Animal with Flyer { } object TraitsApp extends Application { val bird = new Bird bird.breathe }
Listas val fruit = List("uva", "pera", "laranja") val nums = List(1, 2, 3, 4, 5) val diag3 = List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1)) val empty = List()
Operadores básicos sobre listas empty.isEmpty = true fruit.isEmpty = false fruit.head = "uva" fruit.tail.head = "pera" diag3.head = Lista(1, 0, 0)
Created by: 100002303294164
Popular Engineering sets




Use these flashcards to help memorize information. Look at the large card and try to recall what is on the other side. Then click the card to flip it. If you knew the answer, click the green Know box. Otherwise, click the red Don't know box.

When you've placed seven or more cards in the Don't know box, click "retry" to try those cards again.

If you've accidentally put the card in the wrong box, just click on the card to take it out of the box.

You can also use your keyboard to move the cards as follows:

If you are logged in to your account, this website will remember which cards you know and don't know so that they are in the same box the next time you log in.

When you need a break, try one of the other activities listed below the flashcards like Matching, Snowman, or Hungry Bug. Although it may feel like you're playing a game, your brain is still making more connections with the information to help you out.

To see how well you know the information, try the Quiz or Test activity.

Pass complete!
"Know" box contains:
Time elapsed:
restart all cards