ND1 Data Types (MorphEngine v.1.4)
ND1 supports the following data types:

Operators/functions are defined which operate on one or multiple of these types. These are listed under Functions.
Details for each type are as follows:




![ContinuedFraction
A continued fraction in linear notation. Periodic and non-periodic continued fractions are supported.
Examples: [3;7,15,1,292] (approximation of pi), [1;(1)] (golden ratio), [1,(2)] (square root of two)
To enter a continued fraction, use the iOS keyboard and type it in linear notation. Or use the toCF or toSqrtCF function to create one from a real.
There’s a dedicated menu, x/y (Fraction), with functions that operate on continued fractions, allow them to be constructed from Reals, and convert them to Reals, Fractions, convergents, or terms.
A few arithmetic (1/x, neg) and comparison (==, <=, <, etc.) operators, as well as sign, size work on continued fractions.
Note: Periodic continued fractions evaluate to a BigFloat, while non-periodic ones evaluate to a fraction.](ND1_Reference__Data_Types_files/shapeimage_7.png)

![Complex Number ()
A point in the two-dimensional complex plane, usually denoted x+iy, complex numbers in ND1 are denoted (x, y), where x is the real part, and y the imaginary part of the complex number.
Examples: (3, 5), (-2, 4.5653)
When entering a complex number on the edit line, it is not necessary to provide the closing parenthesis.
Almost all operators defined for real numbers also apply to complex numbers. In addition, some operators have an extended range (e.g., square root of a negative number), or produce a complex number as result of an extended range (e.g., inverse sine of a number larger than one).
There’s one menu with operators exclusively for this data type: Complex
Composita:
The components of a complex number can be arbitrary expressions, but they be evaluable by the time the complex number becomes an operand.
Examples: (‘2+3’, 6)
(‘sin(a)+π’, ‘2*b’) [both a and b must be evaluable for this number to be usable in a calculation]
Note: a composita will not display the single quotes when displayed on the stack, but they’re required during entry if the expression is to be retained. The single quotes remain part of the datum and will re-appear upon inspection (edit line / database).
If single quotes are not used during entry, the expression will evaluate immediately.
For example, “(2+3, 6” will enter as (5, 5).](ND1_Reference__Data_Types_files/shapeimage_9.png)

![Vector (Array, List) []
A vector, or array, or list, is a collection of other types: Real Numbers, Complex Numbers, Expressions, Strings, RPL Programs.
In ND1, there’s no distinction in syntax between a mathematical vector, an array, or a list. The word “vector” is mostly used when a mathematical vector is present, otherwise the word “array” is used.
Each member in the collection is referred to as “element”.
If a vector has only number values for its elements, it is a mathematical vector, on which certain operators are defined. Some operators require a vector to have a certain number of elements, called “size”. (For example, the cross-product is only defined on two vectors of size 3, that is, having three elements.)
Examples: [3, 5, 8] (a three-dimensional vector)
[-2, 4.5653] (a two-dimensional vector)
[“A String”, (3,4), ‘sin(x)’] (an array having string, complex number, and expression elements)
When entering a vector on the edit line, it is not necessary to provide the closing bracket.
Various of the common operators (such as “+”, “-”, “neg”) are also defined for mathematical vectors.
There’s one menu with operators exclusively for this data type: Array
Composita:
The elements of an array/vector can be arbitrary types, incl. expressions containing variables.
Select operators are designed to work on arrays with an arbitrary collection of types.
For example, an array [3, ‘3+4’, “Hello “] can be added (“+” operator) to an array [2, ‘sin(r)’, “there”].
Note: expressions in a vector/array will not display the single quotes when displayed on the stack, but they’re required during entry if the expression is to be retained. (If single quotes are not used during entry, the expression will evaluate immediately.) The single quotes remain part of the element and will re-appear upon inspection (edit line / database).
Per-Member Operation:
Built-in functions that operate on a single real-valued input and return one output (of arbitrary type) can be applied to a vector, with the effect of their applying to each member.
For example, “sin” run a vector [π, ‘x’, ‘4-5’] will yield a vector [0, ‘sin(x)’, -0.8414...].](ND1_Reference__Data_Types_files/shapeimage_11.png)
![Matrix [[]]
A matrix is a two-dimensional “grid” of elements of other types: Real Numbers or Expressions. (Complex numbers and other types not yet supported.)
A matrix can be thought of as a vector of vectors, where the size of each component vector is the same.
The word “element” is used to refer to the elements of the vectors, not the vectors themselves.
Examples: [[1, 2],[3,4]]
[[-2, 4.5653], [‘b’,‘a*sin(x)’]]
There’s three ways to enter a matrix on the edit line:
Abbreviated, comma-separated: [[1,2[3,4 [no need for closing brackets]
Abbreviated, space-separated: [[1 2[3 4 [no need for closing brackets]
Full, comma-separated: [[1,2],[3,4]]
Besides the common operators (“+”, “-”, “*”, “/”, “1/x”), operators for this type are in the Array menu.
Composita:
The elements of a matrix can be arbitrary types, incl. expressions containing variables.
Select operators are designed to work on matrices with an arbitrary collection of types.
Note: expressions in a vector/array will not display the single quotes when displayed on the stack, but they’re required during entry if the expression is to be retained. (If single quotes are not used during entry, the expression will evaluate immediately.) The single quotes remain part of the element and will re-appear upon inspection (edit line / database).
Per-Member Operation:
Built-in functions that operate on a single real-valued input and return one output (of arbitrary type) can be applied to a matrix, with the effect of their applying to each member.
For example, “round” run a matrix [[π, 2.3],[4.2, ‘7/2’]] will yield a matrix [[3,2],[4,4]].](ND1_Reference__Data_Types_files/shapeimage_12.png)

![Expression (and Name) ‘’
A mathematical algebraic evaluable expression that, when evaluated, yields exactly one value, where value can be of any type.
Delimited by single quotes, an expression combines literals, variables, operators/functions, and parentheses.
Literals can be of the following types: Real Number, Complex Number, Vector, Matrix
Examples: ‘(2+3)*5‘ (a simple real-valued expression)
‘sin(x)+cos(y)‘ (an expression using one operator (“+”), two functions, and two variables)
‘(4,5)+(2,3)‘ (an expression using one operator (“+”), and two complex number literals)
‘[4,5]+A‘ (an expression using one operator (“+”), one vector literal, and a variable)
‘[[3,4],[1,2]]*[3,4]’ (an expression specifying a literal matrix-vector multiplication)
An expression needs to be algebraically correct. An invalid expression will yield a syntax error when evaluated.
Names
A name looks like an expression but only contains a character sequence. Examples: ‘A’, ‘myVar’, ‘myFunc2’
Names are used as handles for variables and functions. Referring to a name without quotes recalls the variable, and evaluates the function, previously stored under that name.](ND1_Reference__Data_Types_files/shapeimage_14.png)


![JavaScript Objects {}
Native objects in the JavaScript language. A JavaScript Object encapsulates a dictionary of keys and values, where keys are strings, and values can be any valid JavaScript types. Any kind of object can appear on the stack and be used by functions that know how to access its keys (properties).
A generic object will appear on the stack as
[object Object]
The following conventions exists to yield more appropriate information display:
If the object contains a “stringValue” property, it will display instead
If the object is a registered data type, its type’s class will be employed (via toHTML() or toString()) to obtain its visual representation
Objects can be entered on the edit line in standard JavaScript object notation. Generic JavaScript objects can be edited on the edit line (notwithstanding their representation on the stack), as can registered types that permit this.
Examples:
- a user function “function() { return {“a”:1, “b”:”hi” }; }” would, when run, return a dictionary on the stack with a numerical value of 1 for a key named “a”, and a string “hi” for a key named “b”. It would display as [object Object].
- an object entered on the edit line as {“stringValue”: 3.14159} (w/o quotes) would display as 3.14159 on the stack.
There’s no size limitation for a JavaScript object.
There are no functions defined in the shipping function set of ND1 that operate on JavaScript Objects, but nothing precludes user functions to operate on JavaScript objects.
In the future, specific JavaScript Objects may be recognized as new types in the shipping function set.](ND1_Reference__Data_Types_files/shapeimage_17.png)


![TaggedObject
Any of the other supported objects, tagged with a text string.
Examples: :Speed:5 (a Real tagged with string “Speed”)
:Result:587652876587657653234 (a BigInt tagged with string “Result”)
:data:[1,2,3,4] (an array tagged with string “data”)
Entered with special :: syntax, a tagged object decorates another object. It will have limited ability to participate in calculations. Reals will continue to function normally. For example, :Speed:5 can be multiplied by a Real.](ND1_Reference__Data_Types_files/shapeimage_20.png)
Supported Types
(c) 2011 Naive Design. All rights reserved.