feat(tvix/eval): Implement builtins.elem
Change-Id: Id99c1d33f87ad9866990d3483d3531e9e48f861f Reviewed-on: https://cl.tvl.fyi/c/depot/+/6916 Autosubmit: grfn <grfn@gws.fyi> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
b0547ccfa5
commit
8190046190
5 changed files with 82 additions and 0 deletions
|
@ -174,6 +174,14 @@ fn pure_builtins() -> Vec<Builtin> {
|
|||
&[false, false],
|
||||
|args: Vec<Value>, vm: &mut VM| arithmetic_op!(&*args[0].force(vm)?, &*args[1].force(vm)?, /),
|
||||
),
|
||||
Builtin::new("elem", &[true, true], |args: Vec<Value>, vm: &mut VM| {
|
||||
for val in args[1].to_list()? {
|
||||
if val.nix_eq(&args[0], vm)? {
|
||||
return Ok(true.into());
|
||||
}
|
||||
}
|
||||
Ok(false.into())
|
||||
}),
|
||||
Builtin::new("elemAt", &[true, true], |args: Vec<Value>, _: &mut VM| {
|
||||
let xs = args[0].to_list()?;
|
||||
let i = args[1].as_int()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue