Algosim documentation: class

class

Returns the class of an object.

Syntax

Description

If X is any object, then class(X) returns, as a string, the name of the class of X.

Notes

The class function is very similar to type.

While type gives the datatype of an object, class gives the class of it. Although for most objects, the type equals the class, the class concept is a slightly coarser classification. The class of an objects describes its under-the-hood implementation and in some cases two objects can be of the same class but still be of different types.

The main example concerns structures. structure is a class which can be used for any structure. Some structures, however, have a fixed set of keys. Examples of such “typed structures” are date and time structures. These belong to a specific class named typed structure. But their types describe their named key set. Consequently, while both date() and time() have typed structure as their class, their types are structure of type "Date" and structure of type "Time", respectively.

Examples

'(
  1, 1/2, π, i, "nargle", true, sin, (n ↦ n^2 + 1), color("red"),
  ZeroVector(3), IdentityMatrix(10), '(1, 2), {1, 2}, date(),
  ColorGradient(100, 100, "red", "gold"), SineTone(400, 0.1, 1)
 ) @ class
integer
rational number
real number
complex number
string
boolean
kernel function
custom function
color
real vector
real matrix
array
set
typed structure
pixmap
sound

See also