about summary refs log tree commit diff
path: root/tvix/eval/src/builtins
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2022-10-08T19·12-0400
committerclbot <clbot@tvl.fyi>2022-10-10T13·54+0000
commitb6089fb1e516f967bc3f24e9a65c196bed0a9659 (patch)
treec11c20367d20e94cd1fad3799e6638054c304860 /tvix/eval/src/builtins
parentafdf1e0ed02ec6e12a264dcfed18e4ce3028cf2b (diff)
feat(tvix/eval): Implement builtins.concatMap r/5074
Change-Id: I08bfd040a242aa43b64760c19f48a28303f206ac
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6900
Autosubmit: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/eval/src/builtins')
-rw-r--r--tvix/eval/src/builtins/mod.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index b859e2844ee8..e047ef599b2d 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -164,6 +164,19 @@ fn pure_builtins() -> Vec<Builtin> {
             )))
         }),
         Builtin::new(
+            "concatMap",
+            &[true, true],
+            |args: Vec<Value>, vm: &mut VM| {
+                let list = args[1].to_list()?;
+                let mut res = Vec::new();
+                for val in list {
+                    vm.push(val);
+                    res.extend(vm.call_value(&args[0])?.force(vm)?.to_list()?);
+                }
+                Ok(Value::List(res.into()))
+            },
+        ),
+        Builtin::new(
             "div",
             &[false, false],
             |args: Vec<Value>, vm: &mut VM| arithmetic_op!(&*args[0].force(vm)?, &*args[1].force(vm)?, /),