shithub: femtolisp

Download patch

ref: 74d4de6ad5bcac532631d8dfb82d9e6c0435fc0f
parent: b2d65487156e87c7af8ab5ed6d41d78524bed22b
author: Jeff Bezanson <jeff.bezanson@gmail.com>
date: Sat Aug 19 10:19:23 EDT 2017

add function `char-alphabetic?`

--- a/string.c
+++ b/string.c
@@ -242,6 +242,15 @@
     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 @@
 
     { "char.upcase", fl_char_upcase },
     { "char.downcase", fl_char_downcase },
+    { "char-alphabetic?", fl_char_alpha },
 
     { "number->string", fl_numbertostring },
     { "string->number", fl_stringtonumber },