The table below lists the functions available in the BaseFunctions namespace of the Standard Libraries.


FunctionExampleDescription

abstract function == {
    in ref feature x[0..1] : Anything
    in ref feature y[0..1] : Anything

}


calc def Example {
    private import BaseFunctions::**;
    in x : KerML::Feature;
    in y : KerML::Feature;
    x.type == y.type
}
part vehicle : Vehicle {
    part mainEngine : Engine;
    part electricEngine : ElectricEngine;
}
attribute result = Example(vehicle::mainEngine.metadata, vehicle::electricEngine.metadata);

Output

>> result 

false

  • Returns true if x and y are equal in value.

abstract function != {
    in ref feature x[0..1] : Anything
    in ref feature y[0..1] : Anything

}

calc def Example {
    private import BaseFunctions::**;
    in x : KerML::Feature;
    in y : KerML::Feature;
    x.type != y.type
}
part vehicle : Vehicle {
    part mainEngine : Engine;
    part electricEngine : ElectricEngine;
}
attribute result = Example(vehicle::mainEngine.metadata, vehicle::electricEngine.metadata);  

Output

>> result 
true

  • Returns true if x and y are not equal in value.

abstract function === {
    in ref feature x[0..1] : Anything
    in ref feature y[0..1] : Anything

}

 

calc def Example {
    private import BaseFunctions::**;
    in x : KerML::Feature;
    in y : KerML::Feature;
    x.type === y.type
}
part vehicle : Vehicle {
    part mainEngine : Engine;
    part electricEngine : ElectricEngine;
}
attribute result = Example(vehicle::mainEngine.metadata, vehicle::electricEngine.metadata);

Output

>> result 
false

  • Returns true if x and y are identical objects (the same instance).

The operators === and !== apply specifically to values that are occurrences, testing whether two occurrences are portions (in space and/or time) of the same life occurrence. For data values, === and !== are the same as == and !=.

abstract function !== {
    in ref feature x[0..1] : Anything
    in ref feature y[0..1] : Anything

}

 

calc def Example {
    private import BaseFunctions::**;
    in x : KerML::Feature;
    in y : KerML::Feature;
    x.type !== y.type
}
part vehicle : Vehicle {
    part mainEngine : Engine;
    part electricEngine : ElectricEngine;
}
attribute result = Example(vehicle::mainEngine.metadata, vehicle::electricEngine.metadata);

Output

>> result 
true

  • Returns true if x and y are not identical objects (not the same instance).

The operators === and !== apply specifically to values that are occurrences, testing whether two occurrences are portions (in space and/or time) of the same life occurrence. For data values, === and !== are the same as == and !=.

abstract function ToString {
    in ref feature x[0..1] : Anything
}

 

calc def Example {
    private import BaseFunctions::**;
    in x;
    ToString(x)
}
attribute result = Example(5);

Output

>> result 
5

  • Returns the string representation of x.

abstract function # {
    in ref feature seq[0..*] : Anything
    in ref feature index[1..*] : Positive

}

 

calc def Example {
    private import BaseFunctions::**;
    in x;
    in y;
    x#(y)
}
attribute a = (10, 20, 30);
attribute b = 2;
attribute result = Example(a, b);

Output

>> result 
20

  • Returns the element at the specified index position in the sequence. Indexing starts at 1.
  • Related:

abstract function , {
    in ref feature seq1[0..*] : Anything
    in ref feature seq2[0..*] : Anything

}

 

calc def Example {
    private import SequenceFunctions::**;
    in x;
    in y;
    union(x, y)
}
attribute a = (2, 3);
attribute b = (4, 3);
attribute result = Example(a, b);

Output

>> result 
2
3
4
3

  • Enables concatenation of a sequence of values from the inputs.

abstract function istype {
    in ref feature seq[0..*] : Anything
    in ref feature type : Anything

}

 

calc def Example {
    private import BaseFunctions::**;
    in x;
    (x as KerML::Feature).ownedFeature istype SysML::ItemUsage
}
part vehicle {
    part mainEngine;
    part electricEngine;
}
attribute result = Example(vehicle.metadata);

Output

>> result 
true

  • Returns true if all values of x are instances of type t, or of a subtype of t.

abstract function hastype {
    in ref feature seq[0..*] : Anything
    in ref feature type : Anything

}

 

calc def Example {
    private import BaseFunctions::**;
    in x;
    (x as KerML::Feature).ownedFeature hastype SysML::ItemUsage
}
part vehicle {
    part mainEngine;
    part electricEngine;
}
attribute result = Example(vehicle.metadata);

Output

>> result 
false

  • Returns true if all values of x are instances of type t.

abstract function @ {
    in ref feature seq[0..*] : Anything
    in ref feature type : Anything

}

 

calc def Example {
    private import BaseFunctions::**;
    in x;
    (x as KerML::Feature).ownedFeature @ SysML::ItemUsage
}
part vehicle {
    part mainEngine;
    part electricEngine;
    attribute mass;
}
attribute result = Example(vehicle.metadata);

Output

>> result
true

  • Returns true if at least one value of x is an instance of type t, or of a subtype of t. Similar to istype.

abstract function @@ {
    in ref feature seq[0..*] : Metaobject
    in ref feature type : Metaobject

}

 

calc def Example {
    private import BaseFunctions::**;
    vehicle @@ SysML::ItemUsage
    // OR
    vehicle.metadata @ SysML::ItemUsage
}
part vehicle;
attribute result = Example(vehicle);

Output

>> result 
true

  • Tests whether (and returns true if) any metadata associated with an element are classified by the given metaclass. Shorthand for the operator @ and a metadata access expression (.metadata). 

abstract function as {
    in ref feature seq[0..*] : Anything
}

 

calc def Example {
    private import BaseFunctions::*;
    in element : SysML::Package;
    (element as SysML::Package).ownedMember as SysML::PartUsage
}
package UserModel {
    part a;
    part b;
    item c;
}
attribute result = Example(UserModel.metadata);

Output

>> result 
MetadataFeature PartUsage a 
MetadataFeature PartUsage b 

  • Casts x to the specified classifier, i.e., selects elements of the given input that are instances (or subtypes (performs istype)) of the specified classifier.

abstract function meta {
    in ref feature seq[0..*] : Metaobject
}

 

calc def Example {
    private import BaseFunctions::**;
    (vehicle meta SysML::PartUsage) istype SysML::ItemUsage
    // OR

    (vehicle.metadata as SysML::PartUsage) istype SysML::ItemUsage
}
part vehicle;
attribute result = Example(vehicle);

Output

>> result 
true

  • Filters the metadata associated with an element and evaluates to those that are classified by the given metaclass. Shorthand for the operator as and a metadata access expression (.metadata).