Skip to main content

Data Types and Methods

Basic Data Types

TypeIconDescription
ValueValues can be of any type, including String, Number, DateTime, Bool, and Entity.
DictKeys can be either Value, List, or Set, and their length must not exceed 10 characters. The associated values can be of any type.
ListElements within a List can be of any type.

Value types

Value types will only appear in the formula prompt within the formula bar.

TypeIcon
String
Number
Datetime
Bool
Entity

Entity types

Entity types will only appear in the formula prompt within the formula bar.

TypeIcon
Agent
Cell
Link

Data Object Methods

Method NameDescriptionApplicable Data TypeParameter 1Parameter 2Does it modify the original object
deleteDelete an element at a specified index, return the modified original objectList, Dictindex: Int / key: Value
removeDelete a specified value, return the modified original objectList, Setvalue: Any
mergeMerge dictionaries, return the modified original objectDictdicts: Dict, Dict, ...
subObtain a sub-dictionary using a list of indicesDictkeys list: [Value/List/Set]
subCreate a sub-list from a list of indices.Listindexes list: [Int]
subExtract a substring based on a specified position and length.Stringposition: Intlength: Int
extendMerge lists and return the modified original object.Listlists: List, List, ...
appendAppend a value to the end of a list and return the modified original object.Listvalue: Any, Any, ...
insertInsert a value at a certain index in a list and return the modified original object.Listposition: Intvalue: Any
insertAdd a value to a set and return the modified original object.Setvalue: Any
findFind the first index of the specified value in the listListvalue: Any
joinJoin the elements of a list into a string using a specified delimiterListseperator: String
containsCheck if a List contains a specific elementListvalue: Any
containsCheck if a Dict has a specific keyDictkey: Any
containsCheck if a String includes a specific substringStringstr: String
splitSplit a string into a list using a specified characterStringseperator: String
replaceReplace all occurrences of old with new in a string, and return a new stringStringold: Stringnew: String
upperConvert a string to uppercaseStringvalue: String
lowerConvert a string to lowercaseStringvalue: String
sortSort a list in order, returning a new sorted object.Listsort ascending: Trueby=None / lambda
exceptRemove all elements that appear in the given List or Set from the original List or Set object, and return the modified original object.List, Setexclude value: List / Set
choiceRandomly choose a value from a list or setList, Set
popRandomly pop an element from a list or setList, Set
shuffleRandomly rearranges the order of elements in a ListList
copyCopy an objectany
addMove time forwardDateTimedelta:Numberunit='s':String, can be: "d", "h", "m", "s"
minusMove time backwardDateTimedelta:Numberunit='s':String, can be: "d", "h", "m", "s"
deltaCalculate the difference between two datetimeDateTimet2: DateTimeunit='s':String, can be: "d", "h", "m", "s"
timestampGet the timestamp in secondsDateTime

Method Usage

  • Input formulas or expressions in the following format: data_object_name.method().

  • About the List_object.sort method

    Since the system supports using a lambda function for the second parameter (sorting criteria), advanced sorting can be performed on Lists where elements are in Entity, Dict, or List type.

Example

Suppose each student has scores for three courses, and you want to sort the students by their scores. The rule is to first sort by the weighted sum of Math (weight 0.7) and Physics (weight 0.3) scores. If the sums are the same, then sort by Biology scores in descending order.

  • If the three scores are three properties of an Agent, you can try the following expression to achieve multi-level sorting of Student Agent individuals:

    Student.Individuals.copy().sort(False, by=lambda x: [x.Math * 0.7 + x.Physics * 0.3, x.Biology])
  • If student data is stored in a List variable named Students with the element format {"Name": <String>, "Math": <Number>, "Physics": <Number>, "Biology": <Number>}, then you can try the following expression to achieve multi-level sorting of the student List:

    Students.sort(False, by=lambda x: [x["Math"] * 0.7 + x["Physics"] * 0.3, x["Biology"]])
  • If student data is stored in a List variable named Students with the element format [Name<String>, Math<Number>, Physics<Number>, Biology<Number>], then you can try the following expression to achieve multi-level sorting of the student List:

    Students.sort(False, by=lambda x: [x[1] * 0.7 + x[2] * 0.3, x[3]])