The human brain is a very weird device, and I can't tell how many background processes I have running at any one time. I will spend some time learning the boundaries of a particular problem and trying some basic solutions. Then I'll forget about it for a long time. Then I'll wake up with a hunch that I have to try. This happened this morning and netted me a somewhat obscure victory.
I have a quick script on my TI-89Ti to run linear regression on a pair of lists, spit out some statistics and then plot the data and the regression line. It can be a nice thing to have on a portable device. The one glitch that was keeping me from nirvana was that I couldn't easily limit the regression line so as to be plotted in the region encompassed by the data. In "TI-BASIC" (cough cough) the lists for a data plot have to be stored (not program-local) variables, so it makes sense to call the program with pointers to those lists as the arguments:
progName("arg1","arg2")
(putting the quote marks around a variable name turns it into a pointer) and you can then dereference the pointers when you need to in the program code:
LinReg #list1, #list2
where e.g. list1 is the variable name of the first argument defined in the program prototype. You can create a function graph of the resulting regression line with:
Define y1(x)=regeq(x)
but this will give you a line that stretches through +/- infinity (or at least crosses the entire graphics window). So you can constrain the domain of that function using "WITH" limitations, e.g.:
Define y1(x)=regeq(x) | x>0
which will limit the display of the line to the region with the dependent variable greater than zero. I wanted to limit the upper end of the line to the data and you can calculate that as max(#list1) so you *should* be able to use:
Define y1(x)=regeq(x) | x>0 and x<max(#list1)
but the interpreter does not parse that before passing it to the Y= Editor to set it up for function graph display. The ugly method I had been using was to save the x limit as a non-local variable and then referring to it for the limit in the definition. This morning I woke up with the idea of packing the graph definition into an expression that could be interpreted prior to it being delivered to the Y= Editor. So this ended up being:
expr("Define y1(x)=regeq(x) | x>0 and x<max(" & list1 & ")")
Nirvana! The bizarre thing is that I hadn't known that my mind was working on this. I'm now worried that part of my brain's capacity is occupied working on optimising some difficult Lego building exercise from when I was 5. People who say that we only use a fraction of our brain's capacity should probably be forced to qualify the statement to indicate that we're only using a fraction of the brain's capacity "for what we are working on consciously at this moment in time".
