1 #include <Rcpp.h>
2 using namespace Rcpp;
3 
str_islower(std::string str)4 bool str_islower(std::string str){
5 
6   unsigned int input_size = str.size();
7   unsigned int check_nonalpha = 0;
8 
9   for(unsigned int i = 0; i < input_size; i++){
10     if(!islower(str[i])){
11       if(isalpha(str[i])){
12         return false;
13       }
14       check_nonalpha++;
15     }
16   }
17   if(check_nonalpha == input_size){
18     return false;
19   }
20   return true;
21 }
22 
23 //[[Rcpp::export]]
pystr_islower_(CharacterVector strs)24 LogicalVector pystr_islower_(CharacterVector strs){
25 
26   unsigned int input_size = strs.size();
27   LogicalVector output(input_size);
28 
29   for(unsigned int i = 0; i < input_size; i++){
30     if(strs[i] == NA_STRING){
31       output[i] = NA_LOGICAL;
32     } else {
33       output[i] = str_islower(Rcpp::as<std::string>(strs[i]));
34     }
35   }
36 
37   return output;
38 }
39