2

Hey guys I have the following code for a function that finds the range of a function given a restricted domain:

Define resdom(m)=
Func
Local a,b
fMin(m,x) -> a
fMax(m,x) -> b
m(a) -> a
m(b) -> b
return {a,b}
EndFunc

But unfortunately the cas wont calculate m(a), or any m(x) for that matter. If I set the variable in the definition up the top to be "m(x)" instead of "m" it tells me it isn't an appropriate variable.

Any idea how could simply evaluate m(x) inside another function?

Edit:

Just wanted to clarify, I would be calling the function resdom like follows:

Define m(x)=4x
resdom(m(x))
Recessive
  • 1,780
  • 2
  • 14
  • 37
  • 1
    You cannot, unfortunately. Within the context of the TI-Basic language, functions cannot be passed to functions. This is because TI-Basic lacks functional language design because Basic also lacks this. In order to do what you want, you'll need to use assembly language, and pass a function pointer. However, this is rather involved, but if you would like, I can do a write up. – OmnipotentEntity Apr 10 '19 at 16:20
  • 1
    As a remark, the way fMax and fMin get around this limitation is because they are not implemented in TI-Basic. They are implemented in another language and then compiled into assembly. – OmnipotentEntity Apr 10 '19 at 16:23
  • 1
    Excuse me, my information is somewhat outdated, as the last time I did this was in the late 90s. The toolchain is much better now, and by default you can use C. (And the CX Cas uses an arm based chip rather than a z80.) – OmnipotentEntity Apr 10 '19 at 16:29
  • Ok, so in this case how would I feed the pointer to the function `m(x)` into `resdom()`? Or is it not possible to do in the simple editor on the calculator? – Recessive Apr 11 '19 at 00:00
  • 1
    It is simply not doable. You don't have that access. You'll have to approach the problem in a different manner, or use the toolchain I mentioned to compile c code (where you can do that.) – OmnipotentEntity Apr 11 '19 at 00:17
  • 1
    Ahh ok, thanks for the answer! At least I know now. For anyone who might find this, here is a forum post about creating a program in C for nspire: https://www.omnimaga.org/general-calculator-help/how-to-create-a-c-program-for-nspire-cx-cas/ – Recessive Apr 11 '19 at 00:28

0 Answers0