Calculators TI-89 how to save result of an embedded funtion to a variable

Click For Summary
The main issue discussed revolves around executing functions in a programming context where the result needs to be stored in a variable, rather than the function call itself. The user is attempting to call functions and store their outputs, but encounters problems where the variable ends up holding the function call instead of the computed result. This leads to errors when trying to use the stored variable in further calculations or outputs. The user has explored various methods, including defining functions as strings and using expressions to evaluate them, but these approaches have not resolved the core issue. The example provided illustrates a specific function that processes numbers based on a radix, emphasizing the need for a solution that allows for proper execution and storage of function results without resorting to more complex programming techniques. The user seeks a straightforward method to achieve the desired order of execution for function calls.
qqqqq
Messages
1
Reaction score
0
Hello, I do a lot math and physics work, (predominantly advanced fundamental theories), and have consistently been hindered by a particular issue when it comes to a few of my defined functions. I feel like it would be a kind of "order of execution" issue with a simple solution, but though I've scoured the user manual, searched the internet, and even called TI programming support, I haven't been able to figure it out.
Essentially, the Issue I run into is that when I program a function [and part of the issue might be that I do want it to be a "function" and not a "program"], at times, I need to call other functions [or sometimes, recall the function I am currently editing, itself] and actually execute the function completely, and store only the result of the function to a local variable. The problem is that whenever I try to call a function, it stores the function call itself to the variable, rather than the result. For instance, I might have a function like Funct(x,y) which gives let's say {0,1} for x=10, y=12 as an output if executed, so normally, I'd try to store the function/result to a variable like
:Funct(10,12)=>k [assuming of course all the variables are properly defined]
now the issue is that when I go to actually use k in something (the result, I mean; namely {0,1}), like, let's say I want to display the result in a list with other saved variables as an output, it doesn't work right. For instance, if I want to output {k,x,y} which should read {{0,1},10,12} and would seem to be perfectly valid, it would instead give error messages, predominantly b/c (I believe) it's actually trying to execute {Funct(x,y),x,y}, or similar. Now these have just been some examples, however, in other instances for other applications I run into a similar issue.
Is there any way to execute and save some function's (or really any other such statement's) result to a variable, without having to define it as a program and utilize complicated workarounds with external variables (I know such things aren't that complicated, but it's more-so a matter of wanting to call the result as a function for further calculation rather than a programming I/O display)
I have also come up with a few tricks which haven't worked either. For instance, defining my function call as a string, and then using "expr(string)" (which is supposed to immediately execute the string, even within the code), but once again the issue is that saving expr(string)->k or similar just saves the call to the expression, not the actually executed result itself. I believe I've also tried using define to evaluate another function, and return the results of the called function as a result of the defined function (which helps a little in certain cases), but I still end up running into a similar issue when trying to store the result of this newly defined function. For instance, I could use :.Define k(x,y)=Func :Funct(x,y) :EndFunc which might at least execute the internal "Funct(x,y)" part, but I'd still then have to save the result of k(x,y)->kb as I would have had to with Funct(x,y) before.
If it's at all helpful, here's a quick simple function which I ran into the issue with most recently [it simply takes a base idea of numbers, and displays them how they would be coded with regards to an arbitrary radix]. The output should read something like {{{#,#},#},#}, where each # corresponds to the position of a particular symbol in the radix (like (r,n)=(16,12) would mean "12 in hexadecimal" and would output something like {0,12} where 'C' [normal hex symbol for 12] would not be inputted directly, but instead, an arbitrary symbol designation would be outputted, meaning basically 'the 12th symbol in the codec'; Or for example (2,8) would give {{{1,0},0},0}. To clarify, I don't need help with how to program this code in some other way, or how to get this code to work, or other functions which achieve this task more easily/better. All I need help with is the above order of execution question, this is just an example so that whoever needs/wants to, may be able to replicate my issue and see what I mean. [also, as a convention I'm using ":" to indicate line breaks; "=>" to indicate "store"; and (>/=) to indicate "greater than or equal to"]
roll2(r,n) :Func :.Local i,j,k,k2 :0=>i :n=>j :While j (>/=) r :j-r=>j :i+1=>i :EndWhile :n-i*r=>k2 :If n>0 Then :roll2(r,i)=>k :{k,k2} :Else :0=>k :{k,k2} :EndIf :EndFunc
Any help or ideas would be greatly appreciated, this issue has been driving me crazy for a while now, and I keep on running into variants of it.
 
Computer science news on Phys.org
Thanks for the post! Sorry you aren't generating responses at the moment. Do you have any further information, come to any new conclusions or is it possible to reword the post?
 
Thread 'ChatGPT Examples, Good and Bad'
I've been experimenting with ChatGPT. Some results are good, some very very bad. I think examples can help expose the properties of this AI. Maybe you can post some of your favorite examples and tell us what they reveal about the properties of this AI. (I had problems with copy/paste of text and formatting, so I'm posting my examples as screen shots. That is a promising start. :smile: But then I provided values V=1, R1=1, R2=2, R3=3 and asked for the value of I. At first, it said...

Similar threads

Replies
1
Views
5K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 2 ·
Replies
2
Views
29K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
29K
  • · Replies 1 ·
Replies
1
Views
9K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
13K