Okay, here's what I have:


Code:
:If X=1
:Then
:Pt-On(5,7
:Pt-On(6,8
:Pt-On(4,11
...etc
:End
:If X=2
:Then
:Pt-On(11,23
:Pt-On(43,32
...etc
:End


That isn't the exact code, but you get the idea. The code I have is currently 8 pages long, with 90% of it being that above. Is there any way to make it smaller (less size and what not)

NOTE: When I say 8 pages, I write programs in a notebook first, just because I can realize if somethings wrong more easily on paper.
possibly..

instead of having all those Pt-(On commands, just have all the numbers in a list, and call a program with a for( loop that goes to the dim( of the list, by 2.

like For(F,1,dim(List),2
Pt-On(List(F),List(F+1
End

That will save some space that way. Not sure what it would do with speed tho. Might make a couple test programs, copy that data into one of them, and test it out, see what kind of speed difference there is
If there is a pattern associated with those coordinates, it would probably make it easy to write a loop or something to take care of it easily.
One of the big problems you're going to run into is the tradeoff between size and speed. You're probably going to be able to make this much, much smaller, but you're not going to get the speed that you have with a straight linear execution path.
You could try some optimization on it by means of the distributive property, except applied to programming
For instance, this code...

Code:

If X=1
Then
Pt-On(1,1
Pt-On(1,2
End
If X=2
Then
Pt-On(1,1
Pt-On(2,1
End

...if only as is, could be changed to this next code with the same effect:

Code:

Pt-On(1,1
If X=1
Pt-On(1,2
If X=2
Pt-On(2,1

You can do something like this by seeing that regardless of which of the two is true, the same line of code ("Pt-On(1,1") will still be executed, so let the program reflect that.

Also about the trade-off between speed and size KermMartian mentioned. The current coding is basically a loop just unraveled. It's currently set to a speed sort of coding, so if you really want to trade off great speed with small space, make a list, make an algorithm, or use pictures to your advantage. No matter which you choose though, you'll still have to tell it in some way where to turn on all of the points. Keep that in mind.

Code:
:If X=1
:Then
:Pt-On(5,7
:Pt-On(6,8
:Pt-On(4,11
...etc
:End
:If X=2
:Then
:Pt-On(11,23
:Pt-On(43,32
...etc
:End


...becomes...


Code:
:{5,6,4->L1
:{7,8,11->L2
:If X=2
:Then
:{11,43->L1
:{43,32->L2
:End
:For(N,1, dim(L1
:Pt-On(L1(N),L2(N)
:End


But yeah, if theres any pattern between the coordinates, you can greatly reduce the size. If you're drawing lots and lots of coordinates, I would recommend using xLib; this way you can refresh the screen all at once, getting rid of the feeling that the calc is taking forever to draw.
The tradeoff is that with that, even though you can gain significant space savings, you'll probably get slowed down a lot. If it's a game, I tend to try to go with speed first and size second; everything else is the reverse.
can do the list thing in 1 of 2 ways that is more efficient than what rthprog did.

1, have the list as {x,y,x,y,x,y->L1

2, have the list as {x.y,x.y,x.y->L1

With method 1, you would simply do something along the lines of:


Code:

1->A
While A<dim(L1
Pt-On(L1(A),L1(A+1
A+2->A
End


With method 2, you would need to make sure you have the y variable in the hundreths. so if you wanted to turn on x=12, y=4 then the list element 1 would be 12.04. So for the loop, you would need:


Code:

1->A
While A<dim(L1
Pt-On(iPart(L1(A)),[size=7]E[/size]2fPart(L1(A
A+1->A
End


The differences between the two?

Pros:
1 offers a cleaner, and possibly slightly faster execution of the loop.
2 offers a smaller list size, since you can have any value number in a list element and it does not effect the size of the list.

Cons:
1 has larger lists
2 has slightly messier and possibly ever so slightly slower code execution for the loop


Hope this all made some form of sense. XD
If it were a pattern it would be easy to make a loop for it.
Lists work too.
Nice post count tifreak XD
Thats great 6660 post
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement