User Tools

Site Tools


4rpl:data_types

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
4rpl:data_types [2021/03/28 12:21] virgilw4rpl:data_types [2023/01/17 03:38] (current) – [Data types and Coercion] Karsten75
Line 1: Line 1:
 ===== Data types and Coercion ===== ===== Data types and Coercion =====
  
-The following table summarizes the intrinsic data types in 4rpl and how they are coerced. 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).\\+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           ^ float          ^ string          ^ list               ^ table             ^ vector ^ 
-^ int    | int           | float          | ToString        | Empty List         | Empty Table       | V4(int,0,0,0) +^ 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) +^ 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)  +^ 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 | list               | Table from list | V4(List Length,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 | Table Keys as List | table             | V4(Table 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,   | Table of x,y,z,w| vector) +^ vector | Vector Length | Vector Length  | Comma Separated | List of x,y,z,   | Table of x,y,z,w[(TFV> )] | vector |  
 +^ null   | 0             | 0.0            | Empty String    | Empty List         | Empty Table       | V4(0,0,0,0|
  
-*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.\\ 
  
-*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"\\+[(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 ===== ===== Comparisons =====
4rpl/data_types.1616948484.txt.gz · Last modified: 2021/03/28 12:21 by virgilw