- #1
qqqqq
- 1
- 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.
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.