Skip to content

Nspire Reference

Read Stanton edited this page Dec 20, 2020 · 8 revisions

Expression Parsing & Part Function

Part

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:

Other

left and right can also be used under specific circumstances.

Examples:

left(x=1) returns x

right(x=1) returns 1

Type System

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

Program Design

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:

  1. Store the desired return value in a global variable.

    out:=value

  2. 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:


General functions & operators

  • expr(str)
  • #(str of var name)

Useful snippets

Add element to array/list/matrix

rg:=augment(rg, {element})

Convert expression to function

expr("f(x):="&string(fn))

#fn(x)

Clone this wiki locally