Mathcad Express Challenge - faster recursive chr2str function
- October 8, 2025
- 1 reply
- 400 views
My string library defines three different representations of a string, two of which should already be familar: the string and the vector of character codes. The third type is the vector of characters.
In the following, "str" indicates a string, "vec" indicates a vector of character codes, and "chr" represents a vector of characters. For example, chr2str indicates a conversion from a string to a vector of characters.
chr2str itself is relatively quick, even for long strings. chr2str0 has the limitation of hitting Mathcad's recursion depth limit. chr2str2's use of folding over concat, however, is proving somewhat slow once the string length increases to above about 20,000.
The challenge is to define a faster recursive variant of chr2str.

Where the dependencies are as shown below (except the timer functions, which are in an Area at the top of the attached Mathcad Express 11 worksheet).

Stuart

