Skip to content

Instantly share code, notes, and snippets.

@nathanbeddes
Created September 5, 2012 20:41
Show Gist options
  • Select an option

  • Save nathanbeddes/3644397 to your computer and use it in GitHub Desktop.

Select an option

Save nathanbeddes/3644397 to your computer and use it in GitHub Desktop.
object FileMatcher {
private def filesHere = (new java.io.File(".")).listFiles
private def filesMatching(matcher: String => Boolean) =
for (file <- filesHere
if matcher(file.getName))
yield file
def filesEnding(query: String) =
filesMatching(_.endsWith(query))
def filesContaining(query: String) =
filesMatching(_.contains(query))
def filesRegex(query: String) =
filesMatching(_.matches(query))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment