From 74d4de6ad5bcac532631d8dfb82d9e6c0435fc0f Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sat, 19 Aug 2017 14:19:23 -0400 Subject: [PATCH] add function `char-alphabetic?` --- string.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/string.c b/string.c index 83613dc..387cf14 100644 --- a/string.c +++ b/string.c @@ -242,6 +242,15 @@ value_t fl_char_downcase(value_t *args, u_int32_t nargs) return mk_wchar(towlower(*(int32_t*)cp_data(cp))); } +value_t fl_char_alpha(value_t *args, u_int32_t nargs) +{ + argcount("char-alphabetic?", nargs, 1); + cprim_t *cp = (cprim_t*)ptr(args[0]); + if (!iscprim(args[0]) || cp_class(cp) != wchartype) + type_error("char-alphabetic?", "wchar", args[0]); + return iswalpha(*(int32_t*)cp_data(cp)) ? FL_T : FL_F; +} + static value_t mem_find_byte(char *s, char c, size_t start, size_t len) { char *p = memchr(s+start, c, len-start); @@ -412,6 +421,7 @@ static builtinspec_t stringfunc_info[] = { { "char.upcase", fl_char_upcase }, { "char.downcase", fl_char_downcase }, + { "char-alphabetic?", fl_char_alpha }, { "number->string", fl_numbertostring }, { "string->number", fl_stringtonumber },