Advertisement
Guest User

Untitled

a guest
Jun 9th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.63 KB | None | 0 0
  1. sealed case class IntervalVal(val value : IdealInt) extends IntervalInt
  2. {
  3.   override def toString = value.toString
  4. }
  5. case object IntervalNegInf extends IntervalInt
  6. {
  7.   override def toString = "IntervalNegInf"
  8. }
  9. case object IntervalPosInf extends IntervalInt
  10. {
  11.   override def toString = "IntervalNegInf"
  12. }
  13.  
  14.  
  15. abstract class IntervalInt
  16. {
  17. ...
  18.  def isPositive : Boolean =
  19.   {
  20.     println("isPositive(" + this + ")")
  21.     val result = this match
  22.     {
  23.       case (IntervalPosInf) => true
  24.       case (IntervalNegInf) => false
  25.       case IntervalVal(v) => v > 0
  26.     }
  27.     println("Result: " + result)
  28.     result
  29.   }
  30. ...
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement