Permalink
Browse files

Done for the night

  • Loading branch information...
1 parent 946d758 commit 230118d790430dd6a8fcba5ed5d20cd9fdde79cf @alexwhouse committed Mar 3, 2012
View
@@ -1,2 +1,5 @@
classes/
*.*~
+*.jar
+*.class
+
@@ -0,0 +1,4 @@
+val filesHere = (new java.io.File(".")).listFiles
+
+for (file <- filesHere if file.getName.endsWith(".scala"))
+ println(file.getName)
@@ -0,0 +1,10 @@
+val filesHere = (new java.io.File(".")).listFiles
+val classFiles = (new java.io.File("./classes/")).listFiles
+
+val classFileNames = for {
+ file <- classFiles
+ if file.getName.endsWith(".class")
+ } yield file.getName
+
+for (file <- filesHere if file.getName.endsWith(".scala") && (!classFileNames.contains(file.getName.dropRight(".scala".length) + ".class")))
+ println(file)
View
@@ -0,0 +1,16 @@
+val filesHere = (new java.io.File(".")).listFiles
+
+def fileLines(file: java.io.File) =
+ scala.io.Source.fromFile(file).getLines().toList
+
+def grep(pattern: String) =
+ for (
+ file <- filesHere
+ if file.getName.endsWith(".scala");
+ line <- fileLines(file)
+ if line.trim.matches(pattern)
+ ) println(file + ": "+ line.trim)
+
+for (arg <- args)
+ grep(arg)
+
@@ -0,0 +1,14 @@
+val filesHere = (new java.io.File(".")).listFiles
+
+def fileLines(file: java.io.File) =
+ scala.io.Source.fromFile(file).getLines().toList
+
+def grep(pattern: String) =
+ for (
+ file <- filesHere
+ if file.getName.endsWith(".scala");
+ line <- fileLines(file)
+ if line.trim.matches(pattern)
+ ) println(file + ": "+ line.trim)
+
+grep (".*gcd.*")

0 comments on commit 230118d

Please sign in to comment.