Math plug-in: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
mNo edit summary |
mNo edit summary |
||
Line 409: | Line 409: | ||
[[Category:Code Examples]] | [[Category:Code Examples]] | ||
{{InfoBox|Page details| | {{InfoBox|Page details|page-details}} |
Revision as of 04:55, 6 November 2005
Description
This is the file that I had in my computer with all the functions that I made for the Math plug-in. I didn't have enough time to make a documentation for and to arrange those functions below. You're welcome to add a description of use for any function here.
The Functions
;Matrices MatAdd(a,b) (c=-1; x={}; d=#[l(a)>l(b), l(a), l(b)]; #{c++<d, x[c]=a[c]+b[c]}; x) MatSub(a,b) (c=-1; x={}; d=#[l(a)>l(b), l(a), l(b)]; #{c++<d, x[c]=a[c]-b[c]}; x) MatMul(a,b) (c=-1; x={}; d=#[l(a)>l(b), l(a), l(b)]; #{c++<d, x[c]=a[c]*b[c]}; x) MatDiv(a,b) (c=-1; x={}; d=#[l(a)>l(b), l(a), l(b)]; #{c++<d, x[c]=a[c]/b[c]}; x) ;Math Constants Archimedes' Constant - pi = 4*atn(1) pi = 3.14159 e - e = 2.71828 Euler-Mascheroni Constant - gamma = 0.57721 ;Math Formulas Factorial - fac(a, b,c,d) (#[a<0, a*=-1; d=1, d=0]; b=c=1; #{++b<=a, c=c*b}; #[d==1, c*=-1]; d=0; c) Permutation - npr(a, b) (S=c; c=1; #{++b<=a, c=c*b}; a=c; c=S;a) Combination - ncr(a, b) (S=d; S=c; d=b; c=1; #{b++<=a, c=c*(b-1)}; a=b=1; #{a++<=d, b=b*(a-1)}; a=c/b; c=S; d=S; a) Absolute Value (fixed) - abv(a) (#[a < 0, a *= -1, a]) Power (fixed) - poe(a,b, c) (c=1;#{b-->0,c=c*a};c) Sign - sgn(a) (#[a < 0, a = -1, #[a > 0, a = 1, a = 0]]) Fractional Part - fra(a, b) (b=a; a=b-flr(a)) Integer Part - int(a) (flr(a)) Reciprocal - rcp(a) (1/a) Arithmetic Average - avg(a,b) ((a+b)/2) Geometric Average - gav(a,b) (sqr(a*b)) Harmonic Average - hav(a,b) (2/(1/a+1/b)) Prime Numbers - PN(f,t, m,a,b,c,n,i,d,k) (m=sqt(t)+1;a={};b={};c=n=0; i=2; #{i<t, d=k=0; #{(!k)&&(d<n), #[i%(a[d++])==0, k++]}; #[!k,#[i>=f,b[c++]=i];#[i<=m,a[n++]=i,#[i<f,i=f-1]]]; i++}; b) ;Date & Time IsLeapYear(a, b,c) (#[mdf(a/4.0,c) == 0, #[mdf(a/100.0,c) > 0, b = 1, #[mdf(a/400.0,c) == 0, b = 1, b = 0]],b = 0];b) MinToSec(a) (a*60) HourToSec(a) (a*MinToSec(60)) DayToSec(a) (a*HourToSec(24)) MonthToSec(a,b, c) (a--;c=a*DayToSec(31);#[a>=1,#[IsLeapYear(b)==1,c-=DayToSec(2),c-=DayToSec(3)]];#[a>=3, c-=DayToSec(1)];#[a>=5, c-=DayToSec(1)];#[a>=8, c-=DayToSec(1)];#[a>=10, c-=DayToSec(1)];#[a>11, c=0];c) YearToSec(a,b, c) (c=0;#{++b<=a,#[IsLeapYear(a-1),c+=DayToSec(366),c+=DayToSec(365)]};c) DateToSec(a,b,c,d,e,f,g, h) (h=YearToSec(g, a)+MonthToSec(f, a)+DayToSec(e-1)+HourToSec(b)+MinToSec(c)+d;h) r0=DateToSec(2004,0,0,0,1,1,2004) SecToYear(a,b,&c, d) (d=b;#{*c=#[IsLeapYear(d),DayToSec(366),DayToSec(365)];a>=*c,a-=*c;d++};*c=a;d) SecToMonth(a,b,&c, d,e) (d=0; e={31,28,31,30,31,30,31,31,30,31,30,31,0};#{#[d>=12,*c=a+1;d=-1,*c=e[d]*DayToSec(1)];#[(d==1)&&(IsLeapYear(b)),*c+=DayToSec(1)];a>=*c,a-=*c;d++};*c=a;++d) SecToDay(a,&b) (*b=a%DayToSec(1); a=a/DayToSec(1)) SecToHour(a,&b) (*b=a%HourToSec(1); a=a/HourToSec(1)) SecToMin(a,&b) (*b=a%MinToSec(1); a=a/MinToSec(1)) SecToDate(a,b,&c,&d,&e,&f,&g,&h, i) (*h=SecToYear(a,b,i);a=i;*g=SecToMonth(a,b,i);a=i;*f=SecToDay(a,i)+1;a=i;*c=SecToHour(a,i);a=i;*d=SecToMin(a,*e)) SecToDate(5184000,2004,r0,r1,r2,r3,r4,r5) ;Number Types abv(a) (#[a < 0, a *= -1, a]) poe(a,b, c) (c=1;#{b-->0,c=c*a};c) Dec2Hex(a,b, c,d,s,hex) (#[a<0,a=poe(16,b)+a];r2=a;hex={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};s='';#{b-->0,s=hex[a%16]+s; a=a/16};s) r0 = Dec2Hex(-1,2) ;Strings Sort_Bubble(a,c, i,k,t) (i=1;#{i,i=k=0;#{(++k)<c,#[a[k]<(a[k-1]),t=a[k-1];a[k-1]=a[k];a[k]=t;i++]}}) StrLoc(s,e, p,i) (p=-1;i=0;#{(i<l(s))&&(p<0),#[s[i,i+l(e)-1]==e,p=i];i++};p) StrRep(s,fa,ra, i,f,r,e,p) (i=0;#{i<l(fa),e=l(f=fa[i]);r=ra[i];p=0;#{p<l(s),#[s[p,p+e-1]==f,s=(s[,p-1])+r+(s[p+e,]);p+=l(r),p++]};i++};s) ;Geometric Figures AreaSquare(s,A, t,c) (#[s!=0,c|=0x1];#[A!=0,c|=0x2]; #[c==0x1, t=s*s,#[c==0x2, t=sqt(A),#[c==0x3, #[s*s==A, t=1, t=0],t='error']]];t) AreaRectangle(b,h,A, t,c) (#[b!=0,c|=0x1];#[h!=0,c|=0x2];#[A!=0,c|=0x4]; #[c==0x3, t=b*h,#[c==0x5, t=A/b,#[c==0x6, t=A/h,#[c==0x7, #[b*h==A, t=1, t=0], t='error']]]];t) AreaParallelogram(b,h,A, t,c) (#[b!=0,c|=0x1];#[h!=0,c|=0x2];#[A!=0,c|=0x4]; #[c==0x3, t=b*h,#[c==0x5, t=A/b,#[c==0x6, t=A/h,#[c==0x7, #[b*h==A, t=1, t=0], t='error']]]];t) AreaTriangle(b,h,A, t,c) (#[b!=0,c|=0x1];#[h!=0,c|=0x2];#[A!=0,c|=0x4]; #[c==0x3, t=(1/2)*(b*h),#[c==0x5, t=A/(b/2),#[c==0x6, t=A/(h/2),#[c==0x7, #[(1/2)*(b*h)==A, t=1, t=0], t='error']]]];t) AreaRhombus(d1,d2,A, t,c) (#[d1!=0,c|=0x1];#[d2!=0,c|=0x2];#[A!=0,c|=0x4]; #[c==0x3, t=(d1*d2)/2,#[c==0x5, t=A/(d1/2),#[c==0x6, t=A/(d2/2),#[c==0x7, #[(d1*d2)/2==A, t=1, t=0], t='error']]]];t) AreaRegPolygon(a,p,A, t,c) (#[a!=0,c|=0x1];#[p!=0,c|=0x2];#[A!=0,c|=0x4]; #[c==0x3, t=(a*p)/2,#[c==0x5, t=A/(a/2),#[c==0x6, t=A/(p/2),#[c==0x7, #[(a*p)/2==A, t=1, t=0], t='error']]]];t) AreaCircle(r,A, t,c) (#[r!=0,c|=0x1];#[A!=0,c|=0x2]; #[c==0x1, t=r*r*pi,#[c==0x2, t=sqt(A/pi),#[c==0x3, #[r*r*pi==A, t=1, t=0],t='error']]];t) PythagorianTheorem(a,b,c, t,d) (#[a!=0,d|=0x1];#[b!=0,d|=0x2];#[c!=0,d|=0x4]; #[d==0x3, t=sqt((a*a)+(b*b)),#[d==0x5, t=sqt((c*c)-(a*a)),#[d==0x6, t=sqt((c*c)-(b*b)),#[d==0x7, #[(a*a)+(b*b)==(c*c), t=1, t=0], t='error']]]];t) CPythagorianTheorem(a,b,c, t,d) (#[a!=0,d|=0x1];#[b!=0,d|=0x2];#[c!=0,d|=0x4]; #[d==0x3, t=sqt((a*a)+(b*b)),#[d==0x5, t=sqt((c*c)-(a*a)),#[d==0x6, t=sqt((c*c)-(b*b)),#[d==0x7, #[(a*a)+(b*b)>(c*c), t=1, #[(a*a)+(b*b)<(c*c), t=2, t=0]], t='error']]]];t) mtsTQ(s) (s = s(NS); #[s[0]=='$\"',s=s[1,]]; #[s[-1]=='$\"',s=s[,-2]]; NS = s) mtsDL(s) (s=s(NS); p=StrLoc(s,'\r\n'); #[p>=0, (NS=s[p+4,]; NS=#[p>0,s[,p-1],'']), (NS='';NS=s)]) ;Array ArrayInsert(a,s,i, n,nf,nt,s2,t) (t='error'; #[s!='',n=-1;nf=0;s2=0;nt=ArrayLength(a)+1;#{n++<nt,#[n>=i, #[n==i, t=1];#[nf%2==0,#[n!=nt,s2=a[n]];a[n]=s];#[nf%2==1,#[n!=nt,s=a[n]];a[n]=s2];++nf]}];#[t=='error', error='ValueError'];t) # 1: Test = {"A", "B"} ArrayInsert(Test, "C", 2) r0 = Test[2] # Result: 1 - Test = {"A","B","C"} # 2: Test = {"A", "B"} ArrayInsert(Test, "C") r0 = Test[2] # Result: 1 - Test = {"C","A","B"} # Error 1: Test = {"A", "B"} r0 = ArrayInsert(Test) # Result: "error" - Test = {"A", "B"} - error = "ValueError" ArrayAppend(a,s) (t=ArrayInsert(a,s,ArrayLength(a));t) # 1: Test = {"A", "B"} r0 = ArrayAppend(Test, "C") # Result: 1 - Test = {"A", "B", "C"} # Error 1: Test = {"A", "B"} r0 = ArrayAppend(Test) # Result: "error" - Test = {"A", "B"} - error = "ValueError" ArrayCount(a,s, n,nt,t) (t='error';#[s!=0,n=-1;t=0;nt=ArrayLength(a);#{++n<nt, #[a[n]==s, ++t]}, t=ArrayLength(a)];t) # 1: Test = {"A", "B", "C", "A"} r0 = ArrayCount(Test, "A") # Result: 2 - Test = {"A", "B", "C", "A"} # 2: Test = {"A", "B", "C", "A"} r0 = ArrayCount(Test) # Result: 4 - Test = {"A", "B", "C", "A"} ArrayRemove(a,i, n,nf,nt,s,s2,t) (t='error';#[i>=0,n=-1;nf=0;s=s2=0;nt=ArrayLength(a);#{nt-->n,#[nt>=i, #[nt==i, t=a[i]];#[nf%2==0,#[nt!=n,s2=a[nt]];a[nt]=s];#[nf%2==1,#[nt!=n,s=a[nt]];a[nt]=s2];++nf]}];#[t=='error', error='IndexError'];t) # 1: Test = {"A", "B", "C"} r0 = ArrayRemove(Test, 2) # Result: "C" - Test = {"A", "B"} # 2: Test = {"A", "B", "C"} r0 = ArrayRemove(Test) # Result: "A" - Test = {"B", "C"} # Error 1 (Needs to be fixed): Test = {"A", "B", "C"} r0 = ArrayRemove(Test, -1) # Result: "error" - Test = {"A", "B", "C"} - error = "IndexError" ArrayPop(a) (t=ArrayRemove(a,ArrayLength(a)-1);t) # 1: Test = {"A", "B", "C"} r0 = Pop(Test) # Result: "C" - Test = {"A", "B"} ArrayRemoveRepeated(a,s, n,nt,t,f) (#[s==0, f=1];n=-1;nt=ArrayLength(a);t='error';#{#[f==1, s=a[n+1];++n<nt && ArrayCount(a,s)>1,Count(a,s)>1], ArrayRemove(a, ArrayIndex(a,s,2)); t=1};#[t=='error', error='ValueError'];t) # 1: Test = {"A", "B", "C", "A", "B", "C"} ArrayRemoveRepeated(Test, "A") # Result: 1 - Test = {"A", "B", "C", "B", "C"} # 2: Test = {"A", "B", "C", "A", "B", "C"} ArrayRemoveRepeated(Test) # Result: 1 - Test = {"A", "B", "C"} ArrayRemoveItem(a,s,it, i,n,nt,t) (t='error';#[s!="" && i>=0, n=-1;nt=ArrayCount(a,s);i=0;#{++n<=nt, #[a[s]==s, #[i>=it; t=ArrayRemove(a,n)}];#[t!='error',t=1];t) # 1: Test = {"A", "B", "C"} r0 = ArrayRemoveItem(Test, "C") # Result: 2 - Test = {"A", "B", "C"} # Error: // NEEDS VERIFICATION ArrayIndex(a,s,it, f,i,n,nt,t) (t='error';#[s!='',n=-1;nt=ArrayLength(a); i=0;f=0; #[it<0, n=nt;nt=-1;it*=-1;f=1];#[it==0, it=1];#{#[f==1, --n>nt,++n<nt] && i<it, #[a[n]==s, ++i]};#[i>=it, #[f==1, t=++n, t=--n]]];#[t=='error' && s=='',error='ValueError', #[t=='error', error='IndexError']];t) # 1: Test = {"A", "B", "C"} r0 = ArrayIndex(Test, "C") # Result: 2 - Test = {"A", "B", "C"} # 2: Test = {"A", "B", "C", "A"} r0 = ArrayIndex(Test, "A", 2) # Result: 3 - Test = {"A", "B", "C", "A"} # 3: Test = {"A", "B", "C", "A"} r0 = ArrayIndex(Test, "A", -2) # Result: 0 - Test = {"A", "B", "C", "A"} # Error 1: Test = {"A", "B", "C"} r0 = ArrayIndex(Test) # Result: "error" - Test = {"A", "B", "C"} - error = "ValueError" # Error 2: Test = {"A", "B", "C", "A"} r0 = ArrayIndex(Test, "A", 3) # Result: 0 - Test = {"A", "B", "C", "A"} - error = "IndexError" ArraySwap(a,i,i2, s,s2,t) (t='error';#[i==i2,t=1];#[i2>i,s=i;i=i2;i2=s];s=ArrayRemove(a,i);s2=ArrayRemove(a,i2);i2=ArrayInsert(a,s,i2);i=ArrayInsert(a,s2,i);#[i!='error' && i2!='error' && s!='error' && s2!='error',t=1];#[t=='error', error='ValueError'];t) # 1: Test = {"A", "B", "C"} r0 = ArraySwap(Test, 0, 2) # Result: 1 - Test = {"C", "B", "A"} # 2: Test = {"A", "B", "C"} r0 = ArraySwap(Test, 2) # Result: 1 - Test = {"C", "B", "A"} # 3: Test = {"A", "B", "C"} r0 = ArraySwap(Test) # Result: 1 - Test = {"A", "B", "C"} # Error 1: Test = {"A", "B", "C"} r0 = ArraySwap(Test, -2, 0) # Result: 0 - Test = {"A", "B", "C"} - error = "IndexError" ArrayMove(a,i,i2, s,t) (t='error';#[i>=0 && i2>=0,#[i==i2,t=1];s=ArrayRemove(a,i);i=ArrayInsert(a,s,i2);#[i!='error' && s!='error',t=1]];#[t=='error', error='IndexError'];t) # 1: Test = {"A", "B", "C"} r0 = ArrayMove(Test, 0, 2) # Result: 1 - Test = {"B", "C", "A"} # 2: Test = {"A", "B", "C"} r0 = ArrayMove(Test, 2) # Result: 1 - Test = {"C", "A", "B"} # 3: Test = {"A", "B", "C"} r0 = ArrayMove(Test) # Result: 1 - Test = {"A", "B", "C"} # Error 1: Test = {"A", "B", "C"} r0 = ArrayMove(Test, -2, 0) # Result: 0 - Test = {"A", "B", "C"} - error = "IndexError" ArrayExpand(a,a2, n,nt) (n=ArrayLength(a)-1;nt=ArrayLength(a)+ArrayLength(a2);#{++n<nt, a[n]=a2[n-ArrayLength(a2)-1]};a) # 1: Test = {"A", "B", "C"} Test2 = {"D", "E", "F"} r0 = ArrayExpand(Test, Test2) # Result: Test = {"A", "B", "C", "D", "E", "F"} ArrayRange(x,y, a,i) (a={};--x;i=0;#{++x<y, a[i++]=x};a) # 1: Test = Range(0,5) # Result: Test = {"0", "1", "2", "3", "4"} ArrayReverse(a, n,nt,t) (n=-1;nt=ArrayLength(a);#{++n<nt/2.0, t=a[n];a[n]=a[nt-n-1];a[nt-n-1]=t};a) # 1: Test = {"A", "B", "C"} Reverse(Test) # Result: Pointer to "Test" array - Test: {"C", "B", "A"} ArraySort(a,c) (Sort_Bubble(a,c)) # 1: Test = {"C", "B", "A"} Sort(Test) # Result: Pointer to "Test" array - Test: {"A", "B", "C"} ArrayUpdate(a,a2, n,nt,i,t) (n=0;nt=ArrayLength(a2);i=ArrayLength(a);#{n<nt, #[ArrayCount(a, a2[n])==0, ArrayInsert(a, a2[n], i); i++];n++};a) # 1: Test = {"A", "B", "C"} Test2 = {"D", "C", "E"} ArrayUpdate(Test, Test2) # Result: Pointer to "Test" array - Test = {"A", "B", "C", "D", "E"} - Test2 = {"D", "C", "E"} ArrayCopy(a, a2,n,nt,t) (a2 = {};n=0;nt=ArrayLength(a);#{n<nt, ArrayInsert(a2,a[n],n);n++};a2) # 1: Test = {"A", "B", "C"} Test2 = ArrayCopy(Test) # Result: {"A", "B", "C"} - Test = {"A", "B", "C"} - Test2 = {"A", "B", "C"} ArrayCrop(a,n,nt, i) (i=n;#{n<nt, ArrayRemove(a,i);n++};a) # 1: Test = {"A", "B", "C"} r0 = ArrayCrop(Test, 1, 2) # Result: 1 - Test = {"A"} # Error 1: Test = {"A", "B", "C"} r0 = ArrayCrop(Test, 3, -2) # Result: "error" - Test = {"A", "B", "C"} - error = "IndexError" ArrayToString(a,sep, n,nt,t) (n=-1;t="";nt=ArrayLength(a);#{++n<nt, t=t+a[n]+sep};t=t[0,-l(sep)-1];t) StringToArray(s,sep, n,i) (a={};n=-1;#{i = StrLoc(s,sep); i!=-1, a[++n]=s[0,i-l(sep)]; s=s[i+l(sep),-1]};a[++n]=s;a) Sort_Bubble(a,c, i,k,t) (i=1;#{i,i=k=0;#{(++k)<c,#[a[k]<(a[k-1]),t=a[k-1];a[k-1]=a[k];a[k]=t;i++]}}) StrLoc(s,e, p,i) (p=-1;i=0;#{(i<l(s))&&(p<0),#[s[i,i+l(e)-1]==e,p=i];i++};p) ArrayLength(a, i) (i=0;f=0;#{#[a[i] == 0,++f, f=0];f<2, ++i};i-1) ArrayInsert(a,s,i, n,nf,nt,s2,t) (t='error'; #[s!='',n=-1;nf=0;s2=0;nt=ArrayLength(a)+1;#{n++<nt,#[n>=i, #[n==i, t=1];#[nf%2==0,#[n!=nt,s2=a[n]];a[n]=s];#[nf%2==1,#[n!=nt,s=a[n]];a[n]=s2];++nf]}];#[t=='error', error='ValueError'];t) ArrayCount(a,s, n,nt,t) (t='error';#[s!="",n=-1;t=0;nt=ArrayLength(a);#{++n<nt, #[a[n]==s, ++t]}, t=ArrayLength(a)];t) ArrayRemove(a,i, n,nf,nt,s,s2,t) (t='error';#[i>=0,n=-1;nf=0;s=s2=0;nt=ArrayLength(a);#{nt-->n,#[nt>=i, #[nt==i, t=a[i]];#[nf%2==0,#[nt!=n,s2=a[nt]];a[nt]=s];#[nf%2==1,#[nt!=n,s=a[nt]];a[nt]=s2];++nf]}];#[t=='error', error='IndexError'];t) ArrayIndex(a,s,it, f,i,n,nt,t) (t='error';#[s!='',n=-1;nt=ArrayLength(a); i=0;f=0; #[it<0, n=nt;nt=-1;it*=-1;f=1];#[it==0, it=1];#{#[f==1, --n>nt,++n<nt] && i<it, #[a[n]==s, ++i]};#[i>=it, #[f==1, t=++n, t=--n]]];#[t=='error' && s=='',error='ValueError', #[t=='error', error='IndexError']];t) ArrayExpand(a,a2, n,nt,t) (n=ArrayLength(a)-1;nt=ArrayLength(a)+ArrayLength(a2);#{++n<nt, a[n]=a2[n-ArrayLength(a2)-1]};a) ArrayRange(x,y, a,i) (a={};--x;i=0;#{++x<y, a[i++]=x};a) ArrayReverse(a, n,nt,t) (n=-1;nt=ArrayLength(a);#{++n<nt/2.0, t=a[n];a[n]=a[nt-n-1];a[nt-n-1]=t};a) ArrayAppend(a,s) (t=ArrayInsert(a,s,ArrayLength(a));t) ArrayPop(a) (t=ArrayRemove(a,ArrayLength(a)-1);t) ArrayRemoveRepeated(a,s, n,nt,t,f) (#[s==0, f=1];n=-1;nt=ArrayLength(a);t='error';#{#[f==1, s=a[n+1];++n<nt && ArrayCount(a,s)>1,ArrayCount(a,s)>1], ArrayRemove(a, ArrayIndex(a,s,2)); t=1};#[t=='error', error='ValueError'];t) ArrayRemoveItem(a,s,it, i,n,nt,t) (t='error';#[s!="" && i>=0, n=-1;nt=ArrayCount(a,s);i=0;#{++n<=nt, #[a[s]==s, #[i>=it; t=ArrayRemove(a,n)}];#[t!='error',t=1];t) ArraySwap(a,i,i2, s,s2,t) (t='error';#[i==i2,t=1];#[i2>i,s=i;i=i2;i2=s];s=ArrayRemove(a,i);s2=ArrayRemove(a,i2);i2=ArrayInsert(a,s,i2);i=ArrayInsert(a,s2,i);#[i!='error' && i2!='error' && s!='error' && s2!='error',t=1];#[t=='error', error='ValueError'];t) ArrayMove(a,i,i2, s,t) (t='error';#[i>=0 && i2>=0,#[i==i2,t=1];s=ArrayRemove(a,i);i=ArrayInsert(a,s,i2);#[i!='error' && s!='error',t=1]];#[t=='error', error='IndexError'];t) ArraySort(a,c) (Sort_Bubble(a,c)) ArrayUpdate(a,a2, n,nt,i,t) (n=0;nt=ArrayLength(a2);i=ArrayLength(a);#{n<nt, #[ArrayCount(a, a2[n])==0, ArrayInsert(a, a2[n], i); i++];n++};a) ArrayCopy(a, a2,n,nt,t) (a2 = {};n=0;nt=ArrayLength(a);#{n<nt, ArrayInsert(a2,a[n],n);n++};a2) ArrayCrop(a,n,nt, i) (i=n;#{n<nt, ArrayRemove(a,i);n++};a) ArrayToString(a,sep, n,nt,t) (n=-1;t="";nt=ArrayLength(a);#{++n<nt, t=t+a[n]+sep};t=t[0,-l(sep)-1];t) StringToArray(s,sep, n,i) (a={};n=-1;#{i = StrLoc(s,sep); i!=-1, a[++n]=s[0,i-l(sep)]; s=s[i+l(sep),-1]};a[++n]=s;a) ;I need to rename function names to be only for items or for arrays by complete. ;Math Header System: ;To define a number: ;- ${MathNumDef} "numbername" ;To initialize a number: ;- ${MathNumInit} "numbername" "data" "subtype" ;To use a number: ;StrCpy $0 $n_numbername ;RGB <-> HSL ;References http://130.113.54.154/~monger/hsl-rgb.html http://www.easyrgb.com/math.php?MATH=M18#text18 http://en.wikipedia.org/wiki/HSV_color_space http://www.cs.bham.ac.uk/~mer/colour/hsv.html RGBToHSL(R,G,B, RGBMAX,HLSMAX, cMax,cMin,Rdelta,Gdelta,Bdelta) (#[RGBMAX==0,RGBMAX=255.0];#[HLSMAX==0,HLSMAX=240.0];cMin=#[R<G&&R<B,R,#[G<B,G,B]];cMax=#[R>G&&R>B,R,#[G>B,G,B]];L=(((cMax+cMin)*HLSMAX)+RGBMAX)/(2*RGBMAX);#[cMax==cMin,H=(HLSMAX*2.0/3);s=0.0,#[L<=(HLSMAX/2),s=(((cMax-cMin)*HLSMAX)+((cMax+cMin)/2))/(cMax+cMin),s=(((cMax-cMin)*HLSMAX)+((2*RGBMAX-cMax-cMin)/2))/(2*RGBMAX-cMax-cMin)];Rdelta=(((cMax-R)*(HLSMAX/6))+((cMax-cMin)/2))/(cMax-cMin);Gdelta=(((cMax-G)*(HLSMAX/6))+((cMax-cMin)/2))/(cMax-cMin);Bdelta=(((cMax-B)*(HLSMAX/6))+((cMax-cMin)/2))/(cMax-cMin);#[R==cMax,H=Bdelta-Gdelta,#[G==cMax,H=(HLSMAX/3)+Rdelta-Bdelta,#[B==cMax,H=((2*HLSMAX)/3)+Gdelta-Rdelta]]];#[H<0,H+=HLSMAX];#[H>HLSMAX,H-=HLSMAX]];H=#[fra(H)<0.5,H=flr(H),H=cel(H)];s=flr(s);L=flr(L)) RGBToHSL(212,52,97) H - Round normal (when < 0.5, to below, => 0.5, to above) Rest, round downward. Reason: H range of values is 0-239, w/ 240 numbers in total. Numbers never reach above 240, so normal rounding can be applied. S range of values is 0-240, w/ 241 numbers in total. Numbers CAN reach up to 240.5. If it was to be rounded normally, it would go to 241, which wouldn't be good, because no number reached 241. L is the same thing as S. RGB->HLS HueToRGB(n1,n2,H, HLSMAX) (#[HLSMAX==0,HLSMAX=240.0,HLSMAX+=0.0];#[H<0,H+=HLSMAX];#[H>HLSMAX,H-=HLSMAX];#[H<(HLSMAX/6),n1+(((n2-n1)*H+(HLSMAX/12))/(HLSMAX/6)),#[H<(HLSMAX/2),n2,#[H<((HLSMAX*2)/3),n1+(((n2-n1)*(((HLSMAX*2)/3)-H)+(HLSMAX/12))/(HLSMAX/6)),n1]]]) HLSToRGB(H,L,s, HLSMAX,RGBMAX) (#[HLSMAX==0,HLSMAX=240.0];#[RGBMAX==0,RGBMAX=255.0];#[s==0,R=G=B=(L*RGBMAX)/HLSMAX;#[H!=(HLSMAX*2/3),error="ValueError"],#[L<=(HLSMAX/2),Magic2=(L*(HLSMAX+s)+(HLSMAX/2))/HLSMAX,Magic2=L+s-((L*s)+(HLSMAX/2))/HLSMAX];Magic1=2*L-Magic2;R = (HueToRGB(Magic1,Magic2,H+(HLSMAX/3))*RGBMAX+(HLSMAX/2))/HLSMAX;G = (HueToRGB(Magic1,Magic2,H)*RGBMAX + (HLSMAX/2))/HLSMAX;B = (HueToRGB(Magic1,Magic2,H-(HLSMAX/3))*RGBMAX+(HLSMAX/2))/HLSMAX]) Couldn't finish HLSToRGB to accuratelly output consistant results. There is always results in the range 1+/-.