unique and std work, check if delimiter is longer than str

This commit is contained in:
Chad Stearns 2020-09-27 14:27:56 -04:00
parent 5fe6eefa97
commit 43960cf1c6
6 changed files with 108 additions and 3 deletions

View file

@ -51,6 +51,7 @@ pub fn builtin_defs(var_store: &mut VarStore) -> MutMap<Symbol, Def> {
Symbol::BOOL_OR => bool_or,
Symbol::BOOL_NOT => bool_not,
Symbol::STR_CONCAT => str_concat,
Symbol::STR_SPLIT => str_split,
Symbol::STR_IS_EMPTY => str_is_empty,
Symbol::LIST_LEN => list_len,
Symbol::LIST_GET => list_get,
@ -816,6 +817,26 @@ fn list_reverse(symbol: Symbol, var_store: &mut VarStore) -> Def {
)
}
/// Str.split : Str, Str -> List Str
fn str_split(symbol: Symbol, var_store: &mut VarStore) -> Def {
let str_var = var_store.fresh();
let ret_list_var = var_store.fresh();
let body = RunLowLevel {
op: LowLevel::StrSplit,
args: vec![(str_var, Var(Symbol::ARG_1)), (str_var, Var(Symbol::ARG_2))],
ret_var: ret_list_var,
};
defn(
symbol,
vec![(str_var, Symbol::ARG_1), (str_var, Symbol::ARG_2)],
var_store,
body,
ret_list_var,
)
}
/// Str.concat : Str, Str -> Str
fn str_concat(symbol: Symbol, var_store: &mut VarStore) -> Def {
let str_var = var_store.fresh();