(hopefully I haven't made this thread before and then forgotten about it)
Anyways, I'm working on an equation balancer in TI-BASIC. Here's my code so far:
Code:
I'm currently stuck on getting the coefficients into lowest integer ratio. So, the program might produce a coefficient list, {2/3, 3, 1}, which I would need to convert to {2, 9, 3} somehow. I'm not really sure how to do this since there is no command to get the denominator of a fraction, and LCM/GCD only take pairs of integers as input.
Also, I haven't really optimized this yet. I'm waiting until I figure out that part to optimize stuff so that I, and other people, can actually read the code while I am still adding functionality.
also, yay, 400 posts!
Anyways, I'm working on an equation balancer in TI-BASIC. Here's my code so far:
Code:
Ans->Str1
" ->Str2
[[0]]->[A]
{1->|LFMST
{0->|LCPOS
length(Str1->L
1->N
1->C
DelVar P
While L>0
~1+inString("0123456789",sub(Str1,L,1
If Ans!=~1
Then
Ans->N
Else
sub(Str1,L,1
If Ans=")
Then
N->|LFMST(1+dim(|LFMST
1->N
Else
If Ans="(
Then
dim(|LFMST)-1->dim(|LFMST
Else
If Ans="+
Then
C+1->C
dim([A])+{0,1->dim([A]
L+1->|LCPOS(1+dim(|LCPOS
Else
If Ans="-" or Ans=">
Then
If not(P
Then
C->P
C+1->C
dim([A])+{0,1->dim([A]
L+1->|LCPOS(1+dim(|LCPOS
End
Else
If Ans!="
Then
If inString("abcdefghijklmnopqrstuvwxyz",Ans
Then
L-1->L
sub(Str1,L,2->Str3
Else
Ans+" ->Str3
End
inString(Str2,Str3)/2
If not(Ans
Then
Str2+Str3->Str2
dim([A])+{1,0->dim([A]
Ans(1)-1
End
[A](Ans,C)+Nprod(|LFMST->[A](Ans,C
1->N
End
End
End
End
End
End
L-1->L
End
Matr>list(rref([A]),C,|LCOEF
abs(|LCOEF->|LCOEF
1->|LCOEF(dim(|LCOEF
"TD: TO INT RATIO
1+length(Str1->|LCPOS(1
1->|LCPOS(1+dim(|LCPOS
"
For(P,1,dim(|LCPOS)-1
sub(Str1,|LCPOS(P+1),|LCPOS(P)-|LCPOS(P+1))+Ans
If 1!=|LCOEF(P
toString(|LCOEF(P))+Ans
End
sub(Ans,1,length(Ans)-1
I'm currently stuck on getting the coefficients into lowest integer ratio. So, the program might produce a coefficient list, {2/3, 3, 1}, which I would need to convert to {2, 9, 3} somehow. I'm not really sure how to do this since there is no command to get the denominator of a fraction, and LCM/GCD only take pairs of integers as input.
Also, I haven't really optimized this yet. I'm waiting until I figure out that part to optimize stuff so that I, and other people, can actually read the code while I am still adding functionality.
also, yay, 400 posts!