LINUX.ORG.RU

История изменений

Исправление Miguel, (текущая версия) :

Да чего там делать-то?

    sealed trait Term {
      def apply(argument: Term): Term = throw new Exception("Can't apply")
    }
    case class TInt(value: Int) extends Term
    case class TFloat(value: Float) extends Term
    case class TFunction(value: Term => Term) extends Term {
      def apply(argument: Term): Term = value(argument)
    }
Ну, это так, навскидку. Больше фич — больше кода, само собой.

Исправление Miguel, :

Да чего там делать-то?

    sealed trait Term {
      def apply(argument: Term): Term = throw new Exception("Can't apply")
    }
    case class TInt(value: Int) extends Term
    case class TFloat(value: Float) extends Term
    case class TFunction(value: Term => Term) {
      def apply(argument: Term): Term = value(argument)
    }
Ну, это так, навскидку. Больше фич — больше кода, само собой.

Исходная версия Miguel, :

Да чего там делать-то?

[code language=scala] sealed trait Term { def apply(argument: Term): Term = throw new Exception(«Can't apply») } case class TInt(value: Int) extends Term case class TFloat(value: Float) extends Term case class TFunction(value: Term => Term) { def apply(argument: Term): Term = value(argument) } Ну, это так, навскидку. Больше фич — больше кода, само собой.