===== Data types and Coercion ===== The following table summarizes the intrinsic data types in 4RPL and how they are coerced ((Forcible type conversion)). To read the table, look at a datatype in the left column. To see how a variable of that data type is coerced, look across it's row to the column it is being coerced to. For instance, if you treat a string as an int, the "Parse to int" operation will be performed on the int. If you treat a list as a string (say, you trace a list), the list will be turned into comma separate strings (suitable for human eyeball consumption).\\ | ^ int ^ float ^ string ^ list ^ table ^ vector ^ ^ int | int | float | ToString | Empty List | Empty Table | V4(int,0,0,0) | ^ float | int | float | ToString | Empty List | Empty Table | V4(float,0,0,0) | ^ string | Parse To int | Parse To Float | string | Empty List | Empty Table | V4(Parse to float,0,0,0) | ^ list | List Length | List Length | Comma Separated [(TRC>)] | list | Table from list[(TFL>)] | V4(List Length,0,0,0) | ^ table | Table Length | Table Length | Comma Separated [(TRC>)]| Table Keys as List | table | V4(Table length,0,0,0) | ^ vector | Vector Length | Vector Length | Comma Separated | List of x,y,z,w | Table of x,y,z,w[(TFV> )] | vector | ^ null | 0 | 0.0 | Empty String | Empty List | Empty Table | V4(0,0,0,0) | [(TFL>A 'Table from list' is constructed by taking each item in a list and adding it to a table where the item's string representation becomes the key and the item becomes the value.)] [(TFV>A 'Table of x,y,z,w' is constructed by taking each value in a vector and adding it to a table where the keys are "0","1","2","3". )] [(TRC> See note in [[4rpl:commands:asstring|AsString]] command for forcible truncation of lists and tables converted to a string.)] ~~REFNOTES~~ ===== Comparisons ===== Values can be compared using the eq,neq,lt,lte,gt,gte operators. All of these commands take two values and compare them. The following table summarizes the type of comparison that is done based on the types of the two values being compared. A 'float comparison', means that both types are coerced as floats, etc.\\ * If either item being compared is a float, a float comparison is performed.\\ * If both items being compared are strings, a string comparison is performed.\\ * If both items being compared are vectors, a vector comparison is performed.\\ * If one item is a float and one item is a vector, the float is compared to the vector length.\\ * If none of the above conditions are true, an integer comparison is performed.