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

Scala

Trabalho para disciplina de Conceitos e Linguagem de Programação

ConceitoImplementação
Valores imutáveis int x = 10 PS: Uma vez atribuído o valor, ele não poderá ter seu valor alterado durante todo o tempo de vida.
Coleções var listaString = List("palavra", "outra", "mais uma") var listaInt = List(3, 4, 2, 7)
Funções de alta ordem def chamandoFuncao(callback: () => Unit){ println("\nChamando uma função...") callback() }
Casamento de padrões abstract class T case class Num(x: int) extends T case class Plus(left: T, right: T) extends T object Interpreter { def eval(term: T): int = term match { case Num(x) => x case Plus(left, right) => eval(left) + eval(right) } }
Recursividade em 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) }
Funções Anônimas 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...")) } }
Curryng def mod(div: Int)(num :Int) = (num % div) == 0) def main(args: Array[String]):Unit = { for(valor <- 1 to 20) { println("Valor " + valor + " é " + (if (mod(2) (valor)) "par" else "impar" )) } }
Programação orienta a Objeto(Classe) class Complex(real: Double, imaginary: Double) { def re() = real def im() = imaginary }
Herança abstract class Person(val name:String,val age:Int){ override def toString = "Name:"+name+"age:"+age def doSomething; } class Student(name:String,age:Int)extends Person(name,age){ override def doSomething = println(this + " I'm studying!") }
Programação Funcional def qsort(l: List[Int]): List[Int] = { l match { case List() => l case _ => qsort(for(x <- l.tail if x < l.head) yield x) ::: List(l.head) ::: qsort(for(x <- l.tail if x >= l.head) yield x) } }
Membros abstratos abstract class AbsCell { type T; val init: T; private var value: T = init; def get: T = value; def set(x: T): unit = { value = x } } val cell = new AbsCell { type T = int; val init = 1 }
Métodos Genérico def swap[T](x: GenCell[T], y: GenCell[T]): unit = { val t = x.get; x.set(y.get); y.set(t) }
Classe Case abstract class Tree case class Sum(l : Tree, r:Tree) extends Tree case class Var(n : String) extends Tree case class Const(v : Int) extends Tree
For-comprehention object ComprehensionTest1 extends Application { def even(from: Int, to: Int): List[Int] = for (i <- List.range(from, to) if i % 2 == 0) yield i Console.println(even(0, 20)) }
Traits abstract class Animal {def walk:String} trait Injury extends Animal { abstract override def walk = super.walk + quot; But I'm injured :( quot; } class Dog extends Animal{ def walk = quot;I'm walking.quot; } val goodDog = new Dog goodDog.walk
Pattern Match def fac(x : Int) : Int = x match { case 0 => 1 case xpto => xpto * fac(xpto ­ 1) } match val p = new Person(18, quot;Gabrielquot;) val (age, name) = (p.age, p.name) age: Int = 18 name: String = Gabriel
Tupla val t = new Tuple3(1, "hello", Console)
Iterators val it: Iterator[Int] = Iterator.range(1, 100) while (it.hasNext) { val x = it.next println(x * x) }
Streams val fibs: Stream[BigInt] = BigInt(0) #:: BigInt(1) #:: fibs.zip( fibs.tail).map(n => { println("Adding %d and %d".format(n._1, n._2)) n._1 + n._2 }) fibs take 5 foreach println
Expressões Regulares import scala.util.matching.Regex object Test { def main(args: Array[String]) { val pattern = "Scala".r val str = "Scala is Scalable and cool" println(pattern findFirstIn str) } }
Created by: ed.araujo
Popular Computers sets

 

 



Voices

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:
Retries:
restart all cards