mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
List.join builtin and unification
This commit is contained in:
parent
6dd6afbeac
commit
a9ab550c10
6 changed files with 49 additions and 0 deletions
|
@ -61,6 +61,7 @@ pub fn builtin_defs(var_store: &mut VarStore) -> MutMap<Symbol, Def> {
|
|||
Symbol::LIST_REVERSE => list_reverse,
|
||||
Symbol::LIST_CONCAT => list_concat,
|
||||
Symbol::LIST_PREPEND => list_prepend,
|
||||
Symbol::LIST_JOIN => list_join,
|
||||
Symbol::NUM_ADD => num_add,
|
||||
Symbol::NUM_SUB => num_sub,
|
||||
Symbol::NUM_MUL => num_mul,
|
||||
|
@ -903,6 +904,26 @@ fn list_prepend(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
|||
)
|
||||
}
|
||||
|
||||
/// List.join : List (List elem) -> List elem
|
||||
fn list_join(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
let list_var = var_store.fresh();
|
||||
let list_of_list_var = var_store.fresh();
|
||||
|
||||
let body = RunLowLevel {
|
||||
op: LowLevel::ListJoin,
|
||||
args: vec![(list_of_list_var, Var(Symbol::ARG_1))],
|
||||
ret_var: list_var,
|
||||
};
|
||||
|
||||
defn(
|
||||
symbol,
|
||||
vec![(list_of_list_var, Symbol::ARG_1)],
|
||||
var_store,
|
||||
body,
|
||||
list_var,
|
||||
)
|
||||
}
|
||||
|
||||
/// Num.rem : Int, Int -> Result Int [ DivByZero ]*
|
||||
fn num_rem(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
let num_var = var_store.fresh();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue