- Dumping our brains
- 28 May 2020 11:10:25 pm
- Last edited by mr womp womp on 18 May 2021 05:13:40 pm; edited 8 times in total
_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.
Some of these come from me, others I learnt around the internet over the years, sorry if I can't give proper credit.
- On color calcs, using the color tokens (BLUE, RED, BLACK, etc.) is 0.07ms faster than just digits (10,11,12, etc.).
- When performing multiplications, it is considerably faster to have the largest number (in terms of digits) on the left.
- 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)
- 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
- The smallest way to chop off the first element of a list in Ans is ΔList(cumSum(Ans
- The smallest way to chop off the last element of a list in Ans is ΔList(cumSum(Ans)-Ans
- The logic operator "and" is lower than "or" and "xor" in the order of operations , so something like 1 xor 1 and 0 evaluates to true.
- En is faster than 10^n, so when possible, you should use it.
- ~int(~Ans is ceil()
- 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.
- 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.
- toString() is quite a bit faster than eval()
- 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)
- 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]
- int(logBASE(16,2 is 3
- You can do factorials of halves like 2.5! but not other decimal numbers.
- 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 (technically it will return 0.99999999999889 but the calculator will display it as 1. The rand routine cannot actually return 1 but it can get real close)
- For() loops don't check for an overflow when incrementing, so you can go beyond 10^100 like this
- 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.
- Using the built-in list variables L1-L6 is faster than using custom ones like ʟA
- 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...
- 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.
- 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.
- On color calcs, using Line() with linestyle 1 (1px thick) is almost twice as fast as linestyle 2.
Some of these come from me, others I learnt around the internet over the years, sorry if I can't give proper credit.