Navigation Menu

Skip to content

Commit

Permalink
Moved eulergen code into shell script.
Browse files Browse the repository at this point in the history
  • Loading branch information
samskivert committed Mar 23, 2013
1 parent edda77c commit 8bd255f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
eulergen.sh.jar
27 changes: 0 additions & 27 deletions EulerGen.scala

This file was deleted.

33 changes: 28 additions & 5 deletions eulergen.sh
@@ -1,8 +1,31 @@
#!/bin/sh
exec scala -savecompiled $0 $@
!#

if [ ! -d classes ]; then
mkdir classes
fi
scalac -deprecation -d classes EulerGen.scala
import java.io.PrintWriter;
import java.io.FileWriter;
import java.io.File;

scala -cp classes EulerGen $*
object EulerGen {
def main (args :Array[String]) {
if (args.length == 0) {
println("Usage: EulerGen N");
sys.exit(255);
}

val n :Int = Integer.valueOf(args(0)).intValue();
val name = "Euler" + n + ".scala";
val file = new File(name);
if (file.exists()) {
println(name + " already exists.");
sys.exit(255);
}

println("Generating " + name + "...");
val out = new PrintWriter(new FileWriter(file));
out.println("object Euler" + n + " extends EulerApp {");
out.println(" def answer = \"<insert brilliant solution here>\"");
out.println("}");
out.close();
}
}

0 comments on commit 8bd255f

Please sign in to comment.