» Goto page 1, 2  Next
i am having trouble with this code:

Code:
``` :ClrDraw :AxesOff :CoordOff :0→Xmin :94→Xmax :‾62→Ymin :0→YMax :For(A,1,25 :For(B,24,28 :B→L1(A :End :End ```

what i want it to do is store 24-28 into the string five times in that order so that i can make a sprite but when i run it the only number that goes into the list is 28.

Code:
```:ClrDraw :AxesOff :CoordOff :0→Xmin :94→Xmax :‾62→Ymin :0→YMax :For(A,1,25 :For(B,24,28 :B→L1(A+B-24 :End :End ```
It stored 24 into each element, then overwrote each element with 25 until they were overwritten with 28.
See my code above. That's the problem - the inner loop actually runs 25 times, not 5 times.
i tried your code. it put 24 25 times than it put 25,26,27,28
Try this:

Code:
``` :ClrDraw :AxesOff :CoordOff :0→Xmin :94→Xmax :‾62→Ymin :0→YMax :For(A,0,4 :For(B,24,28 :B→L1(5A+B-23 :End :End ```
i put that code in and i got a dimension error.
Sorry. I just realized that and edited my post.

It should be -23 instead of -24

Code:
```:{24,25,26,27,28 :For(A,0,3 :augment(Ans,{24,25,26,27,28 :End :Ans->L1 ```
thanks. the problem is now fixed

Code:
``` :1->C:1->A:23->B :25->dim(L1 :While A<26 :B+C->L1(A :A+1->A :C+1->C :If C=6 :1->C :End ```

This code is tested, and does work.
Mine's smaller.
It seems we have three different routines that do the exact same thing. Which one is better?
i think i will use somethings because it is the fastest
Yay. Also, there's an optimization for size:

Code:
```:{24,25,26,27,28->L1 :For(A,0,3 :augment(Ans,L1 :End :Ans->L1```
More optimization:

:{24,25,26,27,28
:augment(Ans,Ans
:augment(Ans,Ans->L1
That only makes four copies. This should do it

Code:
```:{24,25,26,27,28->L :augment(Ans,Ans :augment(Ans,Ans :augment(Ans,L1->L1 ```

I was just thinking wouldn't this be better using strings?

Code:
```:"24,25,26,27,28, :"{"+Ans+Ans+Ans+Ans+Ans+"0->L1 ```

It would be faster working with strings than lists right? The downside is the +"0 is necessary or you'll get a syntax error.
before i go using the strings one let me see if i understand it. the numbers at the top are to get the ans. than ans is used five times to stick it in five times and the 0 terminates string than it gets stored into list one. oh and it is alot faster. i cant even blink and it is done.
That's all there is to it. In fact, since it is much faster I should start using strings to store to lists instead of doing augment( on a list in the Mario source code. I'll see if it helps the Mario program.
tonight i will have to work on code that can delete that last 0 in the list so that it does not interfere with the sprite drawing.

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.

»
» Goto page 1, 2  Next
» 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