default.txt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * A person has a name and an age.
  3. */
  4. case class Person(name: String, age: Int)
  5. abstract class Vertical extends CaseJeu
  6. case class Haut(a: Int) extends Vertical
  7. case class Bas(name: String, b: Double) extends Vertical
  8. sealed trait Ior[+A, +B]
  9. case class Left[A](a: A) extends Ior[A, Nothing]
  10. case class Right[B](b: B) extends Ior[Nothing, B]
  11. case class Both[A, B](a: A, b: B) extends Ior[A, B]
  12. trait Functor[F[_]] {
  13. def map[A, B](fa: F[A], f: A => B): F[B]
  14. }
  15. // beware Int.MinValue
  16. def absoluteValue(n: Int): Int =
  17. if (n < 0) -n else n
  18. def interp(n: Int): String =
  19. s"there are $n ${color} balloons.\n"
  20. type ξ[A] = (A, A)
  21. trait Hist { lhs =>
  22. def ⊕(rhs: Hist): Hist
  23. }
  24. def gsum[A: Ring](as: Seq[A]): A =
  25. as.foldLeft(Ring[A].zero)(_ + _)
  26. val actions: List[Symbol] =
  27. 'init :: 'read :: 'write :: 'close :: Nil
  28. trait Cake {
  29. type T;
  30. type Q
  31. val things: Seq[T]
  32. abstract class Spindler
  33. def spindle(s: Spindler, ts: Seq[T], reversed: Boolean = false): Seq[Q]
  34. }
  35. val colors = Map(
  36. "red" -> 0xFF0000,
  37. "turquoise" -> 0x00FFFF,
  38. "black" -> 0x000000,
  39. "orange" -> 0xFF8040,
  40. "brown" -> 0x804000)
  41. lazy val ns = for {
  42. x <- 0 until 100
  43. y <- 0 until 100
  44. } yield (x + y) * 33.33