feat(tvix/eval): Implement builtins.concatStringsSep
Change-Id: I6e46bcdbf3b5258b60edb017709fee577eb8ec74 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6907 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
41ddc37725
commit
66a35de3b6
5 changed files with 46 additions and 0 deletions
|
@ -169,6 +169,22 @@ fn pure_builtins() -> Vec<Builtin> {
|
|||
Ok(Value::List(res.into()))
|
||||
},
|
||||
),
|
||||
Builtin::new(
|
||||
"concatStringsSep",
|
||||
&[true, true],
|
||||
|args: Vec<Value>, vm: &mut VM| {
|
||||
let separator = args[0].to_str()?;
|
||||
let list = args[1].to_list()?;
|
||||
let mut res = String::new();
|
||||
for (i, val) in list.into_iter().enumerate() {
|
||||
if i != 0 {
|
||||
res.push_str(&separator);
|
||||
}
|
||||
res.push_str(&val.force(vm)?.coerce_to_string(CoercionKind::Weak, vm)?);
|
||||
}
|
||||
Ok(res.into())
|
||||
},
|
||||
),
|
||||
Builtin::new(
|
||||
"div",
|
||||
&[false, false],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue