Recently, while I was making a program I needed to save a lot of text, so I searched for ways to compress it. After finding Nik's post I made a program that compressess text using his method, but it runs a bit slow. If anybody could help me optimize the code, that would be great.
Compression:
Code:
Decompression:
Code:
Any tips/optimizations/constructive criticism are welcome.
Feel free to ask for explanations.
Compression:
Code:
ClrHome
DelVar FClrList L1
Input "STRING: ",Str1
length(Str1
If Ans/2≠int(Ans/2:Then
"A"+Str1->Str1:1->F:End
1+int((length(Str1)-1)/8->dim(L1
For(A,length(Str1),1,~2
DelVar BDelVar C
For(D,0,1
inString("ABCDEFGHIJKLMNOPQRSTUVWXYZ-' ",sub(Str1,A-D,1->B
C+Ans(not(D->C
End
1+int((3A/2-1)/12->D
Ans≠dim(L1
3(length(Str1)-A)/2-3Ans(length(Str1)-8(dim(L1)-1))/2-24(dim(L1)-Ans-D)/2->E
L1(D)+10^E(100(3int(B/10)+int(C/10))+100fPart(B/10)+10fPart(C/10->L1(D
End
If F:L1(1)-10^(E+1)->L1(1
Decompression:
Code:
ClrHome
" ->Str1
For(E,1,dim(L1
For(A,12,3,~3
int(1000*fPart(L1(E)/(10^A->B
10int(int(B/100)/3)+10fPart(int(B/10)/10->C
round(30fPart(int(B/100)/3)+10fPart(B/10->B
B+.1(B=C->B
For(D,C,B,B-C
If int(D
Str1+sub("ABCDEFGHIJKLMNOPQRSTUVWXYZ-' ",int(D),1->Str1
End:End:End
sub(Str1,2,length(Str1)-1->Str1
Disp Str1
Any tips/optimizations/constructive criticism are welcome.
Feel free to ask for explanations.