Language and Programming
Data Structures
Object Inheritance
More Updates
Allow double as an alias for float[8]
M ≔ Matrix2,2,datatype = double
max/min optionally return position
maxindex1,2,4,3
3
minindex2,1,3,4
2
maxindex,defined1,2,undefined,5,3
4
Objects can now inherit from other object declarations following the usual rules for single inheritance in object-oriented programming. To inherit from an existing declared object, simply include the name of the parent object in parentheses after the object option in the declaration of the descendant object.
Example: Consider a simple definition of a Vehicle object:
You can derive a subclass of Vehicle called Car which inherits properties from Vehicle simply by including the parent object name in the object option when defining the module:
You can see that a Car is a Vehicle:
myCar ≔ ObjectCar:typemyCar, Vehicle
true
SetSpeedmyCar, 88⋅mph
88⁢mph
GetSpeedmyCar
You can also define other objects, such as Bicycle, which inherit from Vehicle:
Notice that while a Bicycle object is a Vehicle, it is not a Car, just as you would expect:
myBike ≔ ObjectBicycle:type Bicycle, Vehicle
type Bicycle, Car
false
Furthermore, if you attempt to access an export such as HasAutomaticTransmission on a Bicycle object, this results in an error, since this export is only provided for a Car object:
myBike:-HasAutomaticTransmission
Error, module does not export `HasAutomaticTransmission`
HasAutomaticTransmissionmyCar
For more details on object inheritance, read about object creation.
cat
Enable concatenation of a string with a constant:
catx=, 2.5
x=2.5
rand
Allow rand to accept floating-point intervals as input:
RealRand ≔ rand0.0 .. 1.0;
→RandomTools:-Generate⁡float⁡'range'=0...1.0,'method'='uniform'
for i to 5 do RealRand end do;
0.8953600369
tablemerge
The new command tablemerge allows two tables to be merged together.
T1 ≔ tablea=100,b=200:
T2≔ tablea=150, c=300:
tablemerge T1, T2
tablea=150,c=300,b=200
In the resulting table, the value associated to key a in T1 was overridden by the value associated to the same key in T2.
If you would prefer they be added, you can specify this by providing a custom merge function:
tablemerge T1, T2, `+`
tablea=250,c=300,b=200
Download Help Document