-
Notifications
You must be signed in to change notification settings - Fork 1
Nspire Reference
part
is an undocumented function which is extremely useful for parsing and extracting expressions.
part(expr)
returns the number of terms within expr
.
part(expr, n)
returns the n
-th term from expr
.
part(expr, 0)
returns the top-level function/operator term from expr
.
Threads about this function:
-
left
andright
can also be used under specific circumstances.Examples:
-
left(x=1)
returnsx
-
right(x=1)
returns1
-
-
exp▶List(Expr, Var)
- Xcalc: Internal Functions
- Xcalc: Internal Functions (Expressions)
- eval_expr (Python utility)
- Misc thread 1
- Structure of expression
getType(var)
can determine variable type.
Name | Type |
---|---|
"DATA" | data variable |
"EXPR" | symbolic expression |
"FUNC" | function |
"LIST" | list |
"MAT" | matrix |
"NONE" | undefined variable |
"NUM" | number |
"OTH" | unknown type |
"PIC" | picture |
"PRGM" | program |
"STR" | string |
"TEXT" | text file |
There are 2 possible program "types" on Nspire: programs and functions. There are considerable differences (which you can read about in official documentation), but the biggest pitfall to using programs instead of functions is that you cannot return values.
It's possible to work around this:
-
Store the desired return value in a global variable.
out:=value
-
Another approach is adding a parameter which is a string of a variable name, then storing the return value in the variable.
#out:=value
Program/Function reference:
expr(str)
#(str of var name)
0≤x≤2π
rg:=augment(rg, {element})
expr("f(x):="&string(fn))
#fn(x)