Julia - 检查字符串中的每个字符是小写还是空格

Tec*_*dle 2 string lowercase julia

如何检查字符串中的每个字符是小写还是空格?

"this is all lowercase"   -> true 
"THIS is Some uppercase " -> false 
"HelloWorld  "             -> false 
"hello world"              -> true
Run Code Online (Sandbox Code Playgroud)

DSM*_*DSM 5

你可以使用谓词/ itr方法all(docs:

julia> f(s) = all(c->islower(c) | isspace(c), s);

julia> f("lower and space")
true

julia> f("mixED")
false
Run Code Online (Sandbox Code Playgroud)