aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-04-02 23:40:18 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-04-02 23:40:18 -0400
commit6eb680f1b77fb35b0966de1aa4a1b187671a525a (patch)
tree956a3efcd61913824534c59462156c720cf91b90
parent728cd8026c1be22713d0e62014faca0be8588775 (diff)
Add array:sample(n, weights)
-rw-r--r--compile.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 08e2fe48..335134e8 100644
--- a/compile.c
+++ b/compile.c
@@ -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")) {