fork download
  1.  
  2. case class Var(name: String) extends Term
  3. case class Fun(arg: String, body: Term) extends Term
  4. case class App(f: Term, v: Term) extends Term
  5.  
  6. object TermTest extends Application {
  7. def printTerm(term: Term) {
  8. term match {
  9. case Var(n) =>
  10. print(n)
  11. case Fun(x, b) =>
  12. print("^" + x + ".")
  13. printTerm(b)
  14. case App(f, v) =>
  15. Console.print("(")
  16. printTerm(f)
  17. print(" ")
  18. printTerm(v)
  19. print(")")
  20. }
  21. }
  22. def isIdentityFun(term: Term): Boolean = term match {
  23. case Fun(x, Var(y)) if x == y => true
  24. case _ => false
  25. }
  26. val id = Fun("x", Var("x"))
  27. val t = Fun("x", Fun("y", App(Var("x"), Var("y"))))
  28. printTerm(t)
  29. println
  30. println(isIdentityFun(id))
  31. println(isIdentityFun(t))
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
cat: /release: No such file or directory
Main.scala:7: error: not found: type Application
object TermTest extends Application {
                        ^
one error found
cat: /release: No such file or directory
Usage: scalac <options> <source files>
where possible standard options include:
  -Dproperty=value                     Pass -Dproperty=value directly to the runtime system.
  -J<flag>                             Pass <flag> directly to the runtime system.
  -P:<plugin>:<opt>                    Pass an option to a plugin
  -X                                   Print a synopsis of advanced options.
  -bootclasspath <path>                Override location of bootstrap class files.
  -classpath <path>                    Specify where to find user class files.
  -d <directory|jar>                   destination for generated classfiles.
  -dependencyfile <file>               Set dependency tracking file.
  -deprecation                         Emit warning and location for usages of deprecated APIs.
  -encoding <encoding>                 Specify character encoding used by source files.
  -explaintypes                        Explain type errors in more detail.
  -extdirs <path>                      Override location of installed extensions.
  -feature                             Emit warning and location for usages of features that should be imported explicitly.
  -g:<level>                           Set level of generated debugging info. Choices: (none,source,line,vars,notailcalls), default: vars.
  -help                                Print a synopsis of standard options
  -javabootclasspath <path>            Override java boot classpath.
  -javaextdirs <path>                  Override java extdirs classpath.
  -language:<_,feature,-feature>       Enable or disable language features: `_' for all, `-language:help' to list choices.
  -no-specialization                   Ignore @specialize annotations.
  -nobootcp                            Do not use the boot classpath for the scala jars.
  -nowarn                              Generate no warnings.
  -opt:<_,optimization,-optimization>  Enable optimizations: `_' for all, `-opt:help' to list choices.
  -opt-warnings:<_,warning,-warning>   Enable optimizer warnings: `_' for all, `-opt-warnings:help' to list choices.
  -print                               Print program with Scala-specific features removed.
  -sourcepath <path>                   Specify location(s) of source files.
  -target:<target>                     Target platform for object files. All JVM 1.5 - 1.7 targets are deprecated. Choices: (jvm-1.5,jvm-1.6,jvm-1.7,jvm-1.8), default: jvm-1.8.
  -toolcp <path>                       Add to the runner classpath.
  -unchecked                           Enable additional warnings where generated code depends on assumptions.
  -uniqid                              Uniquely tag all identifiers in debugging output.
  -usejavacp                           Utilize the java.class.path in classpath resolution.
  -usemanifestcp                       Utilize the manifest in classpath resolution.
  -verbose                             Output messages about what the compiler is doing.
  -version                             Print product version and exit.
  @<file>                              A text file containing compiler arguments (options and source files)

Deprecated settings:
  -optimise                            Compiler flag for the optimizer in Scala 2.11
                                         deprecated: In 2.12, -optimise enables -opt:l:classpath. Check -opt:help for using the Scala 2.12 optimizer.

spoj: The program compiled successfully, but Main.class was not found.
      Class Main should contain method: def main(args: Array[String]).
stdout
Standard output is empty