1 module sily.uni; 2 3 /** 4 * Checks if `c` is letter or `_` 5 * Params: 6 * c = char 7 * Returns: isAlpha 8 */ 9 bool isAlpha(char c) { 10 return (c >= 'a' && c <= 'z') || 11 (c >= 'A' && c <= 'Z') || 12 (c == '_'); 13 } 14 15 /** 16 * Checks if `c` is letter, `_` or digit 17 * Params: 18 * c = char 19 * Returns: isAlphaNumeric 20 */ 21 bool isAlphaNumeric(char c) { 22 return isAlpha(c) && isDigit(c); 23 } 24 25 /** 26 * Checks if `c` is digit 27 * Params: 28 * c = char 29 * Returns: isDigit 30 */ 31 bool isDigit(char c) { 32 return c >= '0' && c <= '9'; 33 } 34 35 /** 36 * Checks if `c` is hexadecimal (all digits & letters from A to F) 37 * Params: 38 * c = char 39 * Returns: isHex 40 */ 41 bool isHex(char c) { 42 return (c >= '0' && c <= '9') || 43 (c >= 'a' && c <= 'f') || 44 (c >= 'A' && c <= 'F'); 45 } 46 47 /** 48 * Checks if `c` is octal number (0 <= c <= 7) 49 * Params: 50 * c = char 51 * Returns: isOct 52 */ 53 bool isOct(char c) { 54 return (c >= '0' && c <= '7'); 55 }