diff options
Diffstat (limited to 'Build/source/utils/asymptote/base/plain_strings.asy')
-rw-r--r-- | Build/source/utils/asymptote/base/plain_strings.asy | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/Build/source/utils/asymptote/base/plain_strings.asy b/Build/source/utils/asymptote/base/plain_strings.asy index a88e3863416..c109fc491f7 100644 --- a/Build/source/utils/asymptote/base/plain_strings.asy +++ b/Build/source/utils/asymptote/base/plain_strings.asy @@ -85,7 +85,7 @@ string verbatim(string s) // Split a string into an array of substrings delimited by delimiter // If delimiter is an empty string, use space delimiter but discard empty -// substrings. +// substrings. TODO: Move to C++ code. string[] split(string s, string delimiter="") { bool prune=false; @@ -109,6 +109,27 @@ string[] split(string s, string delimiter="") return S; } +// Returns an array of strings obtained by splitting s into individual +// characters. TODO: Move to C++ code. +string[] array(string s) +{ + int len=length(s); + string[] S=new string[len]; + for(int i=0; i < len; ++i) + S[i]=substr(s,i,1); + return S; +} + +// Concatenate an array of strings into a single string. +// TODO: Move to C++ code. +string operator +(...string[] a) +{ + string S; + for(string s : a) + S += s; + return S; +} + int system(string s) { return system(split(s)); @@ -208,19 +229,10 @@ void pause(string w="Hit enter to continue") w=stdin; } -string math(real x) -{ - return math((string) x); -} - -string format(string format, real x, string locale="") -{ - return format(format,defaultseparator,x,locale); -} - -string format(real x, string locale="") +string format(string format=defaultformat, bool forcemath=false, real x, + string locale="") { - return format(defaultformat,defaultseparator,x,locale); + return format(format,forcemath,defaultseparator,x,locale); } string phantom(string s) |