From b0faa5adc2c5f56ae50cf21f855fa6805db926cf Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 19 Dec 2024 13:50:35 -0500 Subject: Add Text:from()/to() and Array:slice() for symmetry --- compile.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 770b0191..f4e1e738 100644 --- a/compile.c +++ b/compile.c @@ -2892,6 +2892,10 @@ CORD compile(env_t *env, ast_t *ast) self = compile_to_pointer_depth(env, call->self, 0, false); arg_t *arg_spec = new(arg_t, .name="rng", .type=RNG_TYPE, .default_val=default_rng); return CORD_all("Array$shuffled(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ", ", padded_item_size, ")"); + } else if (streq(call->name, "slice")) { + self = compile_to_pointer_depth(env, call->self, 0, true); + arg_t *arg_spec = new(arg_t, .name="first", .type=INT_TYPE, .next=new(arg_t, .name="last", .type=INT_TYPE)); + return CORD_all("Array$slice(", self, ", ", compile_arguments(env, ast, arg_spec, call->args), ")"); } else if (streq(call->name, "sort") || streq(call->name, "sorted")) { if (streq(call->name, "sort")) EXPECT_POINTER("an", "array"); -- cgit v1.2.3