64 lines
525 B
Julia
64 lines
525 B
Julia
# Problem 3: String Manipulation
|
|
# Concepts: String vs &str, slicing, iteration
|
|
|
|
# Count words in a string, ignoring punctuation:
|
|
|
|
# Input: "Hello, world! How are you?"
|
|
|
|
# Output: 5
|
|
|
|
# Also return vector of unique words (lowercase, no punctuation)
|
|
# ---------------------------------------------- 100 --------------------------------------------- #
|
|
|
|
function main()
|
|
text = "Hello, world! How are you?"
|
|
text_list = split(text, " ")
|
|
println("$(length(text_list))")
|
|
end
|
|
|
|
|
|
|
|
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|