Difference between revisions of "var.storeAt"

From Inspired-Lua Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ var.'''storeAt''' is a function that is part of the Var library.<br /> Stores a numeric value into an element of a math list or matrix with the give...")
 
 
Line 28: Line 28:
 
| <u><center>column</center></u> || number || 1-based column number of the matrix or list.
 
| <u><center>column</center></u> || number || 1-based column number of the matrix or list.
 
|-
 
|-
| <u><center>row</center></u> || number || ''(Optional)'' 1-based row number. ''row'' is only required when recalling a value from a matrix.
+
| <u><center>row</center></u> || number || ''(Optional)'' 1-based row number. ''row'' is only required when storing a value to a matrix.
 
|-
 
|-
 
|}
 
|}

Latest revision as of 13:00, 7 June 2012


var.storeAt is a function that is part of the Var library.

Stores a numeric value into an element of a math list or matrix with the given name.

The value must be numeric. Any other type will raise an error.
New values can be appended to a list by storing to one column past the end of the list.
This function is particularly useful as an optimization when adding new values to a list during a simulation.

Returns nil on success or "cannot store" if the value cannot be stored at the given index.


This has been introduced in TI-Nspire OS 3.2 (Changes).


Syntax

var.storeAt(name, numericValue, column [,row])

Parameter Type Description
name
string Name of the variable to grab from
numericValue
number The numeric value to be stored.
column
number 1-based column number of the matrix or list.
row
number (Optional) 1-based row number. row is only required when storing a value to a matrix.

Example

var.store("mat", {{1,2}, {3,4}}) -- create matrix mat in the symbol table
var.storeAt("mat", 13.3, 1, 1) -- puts the number 13.1 into the field 1,1 of the matrix
val = var.recallAt("mat", 1, 1) -- grab it back in lua

Good to know

Routines var.recallAt and var.storeAt will work with matrices but only if they are created by some other means (var.store) :

See also