🕸📝Fergus Duniho wrote on Sat, Mar 12, 2022 03:37 AM UTC:
I have added the following built-in functions: chars, string, hasalnum, hasalpha, hasdigit, haslower, and hasupper. The chars and string functions can be used together to process a string with a lambda function filter, using chars to turn a string into an array of characters, and using string to converted the processed array back into a string. For example, promoted pieces in Shogi put a plus sign before the usual piece label, and the boldfaced part of this line demotes a piece in Shogi by removing any non-alphabetic characters:
set demoted flipcase realname string filter lambda (isalpha #1) chars alias space $dest;
The has functions are similar to isalnum, isalpha, isdigit, islower, and isupper, but instead of checking whether every character in a string is of a particular type, these check whether any character, even just one, is of a particular type. These come in handy when piece labels include non-alphabetic characters, as promoted pieces do in Shogi.
I have added the following built-in functions: chars, string, hasalnum, hasalpha, hasdigit, haslower, and hasupper. The chars and string functions can be used together to process a string with a lambda function filter, using chars to turn a string into an array of characters, and using string to converted the processed array back into a string. For example, promoted pieces in Shogi put a plus sign before the usual piece label, and the boldfaced part of this line demotes a piece in Shogi by removing any non-alphabetic characters:
set demoted flipcase realname string filter lambda (isalpha #1) chars alias space $dest;
The has functions are similar to isalnum, isalpha, isdigit, islower, and isupper, but instead of checking whether every character in a string is of a particular type, these check whether any character, even just one, is of a particular type. These come in handy when piece labels include non-alphabetic characters, as promoted pieces do in Shogi.