User:Piphi/Asymptote/piphi
< User:Piphi | Asymptote
My own unofficial Asymptote module with some useful functions:
- This function is actually part of newer versions of Asymptote, but is not supported in 2.32 so I decided to make it. What it does is it takes a string and splits it into individual characters.
string [] array (string s) {
string[]strarray;
for (int i=0;i<length(s);++i) {
strarray[i]=substr(s,i,1);
}
return strarray;
}
- returns the number of digits in the given integer.
int length (int i) {
int j=0;
bool brk=false;
do {
++j;
if (i/(10**j) < 1) {
brk=true;
}
} while (!brk);
return j;
}
- converts strings into integers.
int int (string s) {
string[]a=array(s);
int b;
for (int i=0;i<a.length;++i)
b+=(ascii(a[i])-48)*10**(a.length-i-1);
return b;
}
More to come...