mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 02:39:20 +00:00
feat: add Array.repeat
This commit is contained in:
parent
b9cb197a6f
commit
48cdd2462d
4 changed files with 27 additions and 1 deletions
|
@ -1603,7 +1603,7 @@ impl Context {
|
|||
2,
|
||||
);
|
||||
array_add.register_builtin_erg_impl(OP_ADD, t, Immutable, Visibility::BUILTIN_PUBLIC);
|
||||
let out_t = array_t(T.clone(), N.clone() + M);
|
||||
let out_t = array_t(T.clone(), N.clone() + M.clone());
|
||||
array_add.register_builtin_const(
|
||||
OUTPUT,
|
||||
Visibility::BUILTIN_PUBLIC,
|
||||
|
@ -1619,6 +1619,19 @@ impl Context {
|
|||
)
|
||||
.quantify();
|
||||
array_.register_builtin_erg_impl(FUNC_PUSH, t, Immutable, Visibility::BUILTIN_PUBLIC);
|
||||
let repeat_t = no_var_fn_met(
|
||||
arr_t.clone(),
|
||||
vec![pos(singleton(Nat, M.clone()))],
|
||||
vec![],
|
||||
array_t(T.clone(), N.clone() * M.clone()),
|
||||
)
|
||||
.quantify();
|
||||
array_.register_builtin_erg_impl(
|
||||
FUNC_REPEAT,
|
||||
repeat_t,
|
||||
Immutable,
|
||||
Visibility::BUILTIN_PUBLIC,
|
||||
);
|
||||
// [T; N].MutType! = [T; !N] (neither [T!; N] nor [T; N]!)
|
||||
let mut_type =
|
||||
ValueObj::builtin_class(poly(MUT_ARRAY, vec![TyParam::t(T.clone()), N.clone()]));
|
||||
|
|
|
@ -243,6 +243,7 @@ const FUNC_DEDUP: &str = "dedup";
|
|||
const FUNC_CONCAT: &str = "concat";
|
||||
const FUNC_DIFF: &str = "diff";
|
||||
const FUNC_PUSH: &str = "push";
|
||||
const FUNC_REPEAT: &str = "repeat";
|
||||
const PROC_PUSH: &str = "push!";
|
||||
const FUNC_MERGE: &str = "merge";
|
||||
const PROC_MERGE: &str = "merge!";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue