17 lines
578 B
EmacsLisp
17 lines
578 B
EmacsLisp
// count-lines-words-letters.el — composite count test.
|
|
// Input "Hello world\nGoodbye world\n":
|
|
// lines: 2 (each \n closes a line)
|
|
// words: 4 (Hello, world, Goodbye, world)
|
|
// letters: 22 (Hello=5 + world=5 + Goodbye=7 + world=5)
|
|
fn run_test() -> String {
|
|
let s: String = "Hello world\nGoodbye world\n"
|
|
let lines: Int = str_count_lines(s)
|
|
let words: Int = str_count_words(s)
|
|
let letters: Int = str_count_letters(s)
|
|
return int_to_str(lines) + "/" + int_to_str(words) + "/" + int_to_str(letters)
|
|
}
|
|
|
|
fn main() -> Void {
|
|
println(run_test())
|
|
}
|