Examples of HorseIR¶
Data printing¶
We propose a couple of pretty printing modes as follows.
- Print all elements (real numbers, complex numbers and symbols)
- Print abbreviations for advanced types (nested lists, dictionary, enumeration, tables and keyed tables)
- Print customized sizes (e.g. 20 rows and 5 columns max)
- Print within current window (Optional)
Basic types¶
Bool¶
(0,1):bool
Short¶
(10,20):i16
Int¶
(1234567,2):i32
Long¶
(123456789012345,123):i64
Float¶
(12.3,2.5):f32
Double¶
(12.3,2.5):f64
Char¶
'abcd':char
Complex numbers¶
(1+2i,2,3i):complex
Symbols¶
(`apple,`"my name"):sym
Compound types¶
List¶
Input literal:
@list((1,2,3):i32, (2,0.5):f32)
Output:
((1,2,3):i32, (2,0.5):f32):list<?>
Dictionary¶
Input literal:
key:sym = (`key1,`key2):sym;
value:sym = @list((1,2,3):i32, (2,0.5):f32);
@dict(key, value);
Output:
{
`key1 -> (1,2,3):i32,
`key2 -> (2,0.5):f32
}
Enumeration¶
Input literal:
enum_u = `u:sym;
enum_v = (`a,`b,`c):sym;
@enum(enum_u, enum_v);
Output:
<`u, (`a,`b,`c)>
Table¶
Input literal:
table_names:sym = (`col1, `col2):sym;
table_values:list<?> = @list((`a,`b,`c):str, (1,2,3):i32);
@table(table_names, table_values);
Output:
col1 col2
---------
a 1
b 2
c 3
Keyed table¶
Input literal:
key_table:table = @table(`col1:sym, (`a,`b,`c):sym);
value_table:table = @table(`col2:sym, (1,2,3):i32);
@ktable(key_table, value_table);
Output:
col1 | col2
-----------
a | 1
b | 2
c | 3