Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 40 lines (36 sloc) 1.06 KB
#!/usr/local/bin/julia
const DEF = "tests/one.txt"
const files = length(ARGS) == 0 ? (println("please provide at least one file name!\n > RUNNING $DEF"); [DEF]) : ARGS
const delims = [' ','\n','\t','.',',','(',')','?','/'] # single quotes: character literal
function getstr(file)
f = open(file)
str = readstring(f)
close(f)
str
end
type wordlist
file::String
words::Dict{String,Int}
string::String
addword::Function
function wordlist(file::String)
this = new(file)
this.words = Dict{String,Int}()
this.string = getstr(this.file)
this.addword = function(word)
haskey(this.words, word) ? this.words[word] += 1 : this.words[word] = 1
this.words[word]
end
map(word->this.addword(word),split(this.string,delims))
this
end
end
file_o = [wordlist(file) for file in files]
for wl in file_o
println("$(typeof(wl)) \"obj\"")
for field in fieldnames(wl)
s = String(field)
println("\n__wl.$(s)__")
println(getfield(wl,Symbol(field)))
end
end