Author Topic: Answer Programs  (Read 5573 times)

0 Members and 1 Guest are viewing this topic.

_player1537

  • Guest
Re: Answer Programs
« Reply #15 on: August 29, 2010, 02:15:03 am »
sorry for the necropost :P

Quote from: calcdude84se
The main problem is with modifying a single value in a list. Using augment( and seq(, despite being the only way to do it, is slow for a large number of values.

On mine, I always just updated the entire list at once:
{ans(1),ans(2),ans(3)+(ans(1)=26)-(ans(1)=24)
{ans(1),ans(2)+1,ans(3)
<etc>

Oh, and for displaying scores, I typically use (assuming ans(1) is my getkey position:
Disp <score>
repeat ans(1
{getKey,<rest of the ans(x) statements>
End

Oh, and to set a variable without disrupting answer:
for(B,-500,<value to set (>-500)>:End

And sometimes, for subroutines, or when I don't want to hard code the positions in (might make sense in the example, or for example when using disp or output() statements), I use:
augment(ans,{value(s)
Output(ans(dim(ans)),1,"The Game
Output(ans(dim(ans)-1),3,"You lost!

I can't really think of any other Answer routines, if I do I'll post/edit them in.  If you have any, post them :)


(Oh, and for the asteroids game, it was coming along quite nicely :D  I think I have it saved in one of my backups somewhere.  It ran really quickly (or looked like it ;)) As did my galaxian clone answer program :D)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Answer Programs
« Reply #16 on: August 29, 2010, 02:17:28 am »
Oh, and to set a variable without disrupting answer:
for(B,-500,<value to set (>-500)>:End

Doesnt For(B,#,#):End Also work to set B to #+1?

_player1537

  • Guest
Re: Answer Programs
« Reply #17 on: August 29, 2010, 02:20:13 am »
Yep :)