diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-04-02 23:40:18 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-04-02 23:40:18 -0400 |
| commit | 6eb680f1b77fb35b0966de1aa4a1b187671a525a (patch) | |
| tree | 956a3efcd61913824534c59462156c720cf91b90 | |
| parent | 728cd8026c1be22713d0e62014faca0be8588775 (diff) | |
Add array:sample(n, weights)
| -rw-r--r-- | compile.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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")) { |
