Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved eulergen code into shell script.
- Loading branch information
1 parent
edda77c
commit 8bd255f
Showing
3 changed files
with
29 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
eulergen.sh.jar |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |