Add array:sample(n, weights)
This commit is contained in:
parent
728cd8026c
commit
6eb680f1b7
@ -1484,7 +1484,8 @@ CORD compile(env_t *env, ast_t *ast)
|
||||
} else if (streq(call->name, "sample")) {
|
||||
CORD self = compile_to_pointer_depth(env, call->self, 0, false);
|
||||
arg_t *arg_spec = new(arg_t, .name="count", .type=Type(IntType, .bits=64),
|
||||
.next=new(arg_t, .name="weights", .type=self_value_t, .default_val=FakeAST(Array)));
|
||||
.next=new(arg_t, .name="weights", .type=Type(ArrayType, .item_type=Type(NumType, .bits=64)),
|
||||
.default_val=FakeAST(Array, .type=new(type_ast_t, .tag=VarTypeAST, .__data.VarTypeAST.name="Num"))));
|
||||
return CORD_all("Array$sample(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", ",
|
||||
compile_type_info(env, self_value_t), ")");
|
||||
} else if (streq(call->name, "shuffle")) {
|
||||
|
Loading…
Reference in New Issue
Block a user