diff options
author | William Carroll <wpcarro@gmail.com> | 2022-08-30T00·33-0700 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-07T20·56+0000 |
commit | 197fe37daef242596900bcab948d6fc14348f910 (patch) | |
tree | ae7daee7509d03cd2b18fbc2aa16a61dc28f35f6 /tvix/eval/src/builtins | |
parent | 15e2bc54f1beab0f99a7d7199af92a3139052302 (diff) |
feat(tvix/eval): Support builtins.length r/4740
Get the length of a list Change-Id: I41d91e96d833269541a1b3c23b7cc879f96d1e5a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6407 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src/builtins')
-rw-r--r-- | tvix/eval/src/builtins/mod.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index 1a0443cb6012..3c32129e0537 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -45,6 +45,9 @@ fn pure_builtins() -> Vec<Builtin> { let a = args.pop().unwrap(); Ok(arithmetic_op!(a, b, /)) }), + Builtin::new("length", 1, |args| { + Ok(Value::Integer(args[0].as_list()?.len() as i64)) + }), Builtin::new("isAttrs", 1, |args| { Ok(Value::Bool(matches!(args[0], Value::Attrs(_)))) }), |