_iPhoenix_ suggested I should make a thread where I dump some random TI-Basic knowledge. There are definitely some users out there that are more knowledgeable so I encourage them to throw in some quirks that I don't mention. Obviously this'll just be a mashup of random things that come to mind in no particular order. I might add some in the future.
  1. On color calcs, using the color tokens (BLUE, RED, BLACK, etc.) is 0.07ms faster than just digits (10,11,12, etc.).
  2. When performing multiplications, it is considerably faster to have the largest number (in terms of digits) on the left.
  3. System variables (finance vars, window vars, recursive n, etc. ) are 0.5ms faster than the OS variables (A, B, C, D, etc.) Ans isn't as fast as system variables, but it can be faster than storing to a variable depending on context. On the TI-83 series, the difference is even bigger (1.3ms)
  4. The smallest way to generate a list of numbers 1...n is cumSum(binomcdf(n-1,0. However, if you already have a list L1 of dimension n, you can do cumSum(1 or L1, and if you don't care about the order, you can do randIntNoRep(1,n,n
  5. The smallest way to chop off the first element of a list is ΔList(cumSum(Ans
  6. The smallest way to chop off the last element of a list is ΔList(cumSum(Ans)-Ans
  7. The logic operator "and" is lower than "or" and "xor" in the order of operations , so something like 1 and 0 xor 1 evaluates to true.
  8. En is faster than 10^n, so when possible, you should use it.
  9. ~int(~Ans is ceil()
  10. Vertical text sprites are generally faster than horizontal text sprites. Also, for horizontal text sprites, there is no token that will produce 01011 as its left-most pixels, but there are tokens for all 31 other combinations.
  11. sum() can be used to get the nth element of a list inline by setting the 2nd and 3rd arguments to n (eg. sum({1,2,3},3,3 returns the 3). Speaking of which, both sum() and prod() have seldom-used optional 2nd and 3rd arguments which specify start and end positions.
  12. toString() is quite a bit faster than eval()
  13. GetCalc(A:e(A=π)+π(A≠π→A will set A to π on one calculator and e on the other, allowing for two connected calculators to run the same program in a turn-based fashion. (from tibasicdev)
  14. I don't think this is intentional but in the DCSE8 SDK, there is a command that isn't documented which is DrawInt(), it is used to draw a colored int with a transparent background to the active GRAM buffer. It is used as follows: real(6,9,X,Y,[color code],[expr]
  15. int(logBASE(16,2 is 3 Laughing
  16. You can do factorials of halves like 2.5! but not other decimal numbers.
  17. I don't think a lot of people know that you can seed the random number generator like this: [seed]→rand. Also 196164532 is the seed to generate 1 so 196164532→rand:rand will return 1
  18. For() loops don't check for an overflow when incrementing, so you can go beyond 10^100 like this
  19. An unclosed parenthesis at the end of a For() line is considerably slower if the following line is either an If without a Then:End, or an IS>( or DS<( statement and the condition is false.
  20. Using the built-in list variables L1-L6 is faster than using custom ones like ʟA
  21. This one isn't particularly obscure, but you don't need a newline at the end of a DelVar command, so you can save a byte by doing something like DelVar AIf A=0...
  22. If the very last line of a program is value-returning, the value will be displayed on the homescreen. There will also be no "Done" if you do this.
  23. There is an undocumented optional first argument for the Text() command which, if set to -1, will display the text on the graph screen in the home screen font.

Some of these come from me, others I learnt around the internet over the years, sorry if I can't give proper credit.
This is great! Long, long ago, The BASIC Elite made a guide called The 1337 Guide to TI-BASIC that 15 years ago, I'm still proud of, but I (and the community) have definitely learned way, way more in that intervening decade and a half. Please do share your (collective) tips and tricks here, and depending on people's willingness for those tips to go further, I'd potentially be interested in updating the 1337 Guide.
I have one.

You can store 4 values in 1 variable, or list or matrix element by doing:

Code:
value1+value2/|E3+value3[i]+value4[i]/|E3->N

Where |E is the mathematical operator and [i] represents the imaginary i. E3 should be increased if your values are more than 3 digits long.

This results in a number like 1.002+3.004i

You can get the individual values back like this:

Code:
value1 = real(iPart(N
value2 = real(|E3fPart(N
value3 = imag(iPart(N
value4 = imag(|E3fPart(N
Michael2_3B wrote:
I have one.

You can store 4 values in 1 variable, or list or matrix element by doing:

Code:
value1+value2/|E3+value3[i]+value4[i]/|E3->N

Where |E is the mathematical operator and [i] represents the imaginary i. E3 should be increased if your values are more than 3 digits long.

This results in a number like 1.002+3.004i

You can get the individual values back like this:

Code:
value1 = real(iPart(N
value2 = real(|E3fPart(N
value3 = imag(iPart(N
value4 = imag(|E3fPart(N

I wouldn't be surprised if this could be expanded to 5-6 values specifically on the 83PCEEP.

Besides that, I felt really dumb after reading mr womp womp's post, thinking I had pretty much mastered TI-BASIC over the years. There's always more to learn I guess. Razz
After seeding 42→rand, int(9rand(8 gives eight unique values with evens on the left, odds on the right.

One not-so-outlandish application is in menuing (see the careful reordering of label arguments):


Code:
42→rand
Menu("","ALICE",7,"BOBBY",1,"CAROL",5,"DAVID",2,"ELISA",4,"FRANK",3,"GRACE",6
Lbl 1:rand
Lbl 2:rand
Lbl 3:rand
Lbl 4:rand
Lbl 5:rand
Lbl 6:rand
Lbl 7
Disp sub("ALICEBOBBYCAROLDAVIDELISAFRANKGRACE",5int(9rand)-9,5)+" IS COOL!


This saves a handful of bytes over using Ans+1 each label prior to dictionary lookup you may have seen me use before.
  
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 GMT - 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