Skip to content

Instantly share code, notes, and snippets.

@kyonmm
Created May 31, 2013 04:40
Show Gist options
  • Select an option

  • Save kyonmm/5682974 to your computer and use it in GitHub Desktop.

Select an option

Save kyonmm/5682974 to your computer and use it in GitHub Desktop.
F# のコメントと空白行を除いた行数を出力します。ざっくり実装です。起動引数にディレクトリを指定すると、配下のフォルダ全てのfsファイルを対象に行数を出力します。
import groovy.io.FileType
def multiLineComment = false
new File(args[0])
.eachFileRecurse(FileType.FILES){
if(it.name.endsWith("fs") == false) { return }
println it.name + "\t" + it.grep{it.trim().startsWith("//") == false}
.grep{
if(it.trim().contains("(*")){
multiLineComment = true
}
if(it.trim().contains("*)")){
multiLineComment = false
}
!multiLineComment}
.grep{it.trim().size() != 0}
.size()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment