diff options
author | James Landrein <james.landrein@gmail.com> | 2022-10-17T21·37+0200 |
---|---|---|
committer | j4m3s <james.landrein@gmail.com> | 2022-10-25T08·46+0000 |
commit | 8425c2016c9a29008cdec8414fc647b8076a7e34 (patch) | |
tree | 1d11af3c83a0529ab44ceb925761779acb16c7fa /tvix/eval/src/builtins | |
parent | bd0bf6ea7d64d2b3b453db4adb94c98c0b459a24 (diff) |
feat(tvix/eval): add builtins.{floor,ceil} r/5198
Change-Id: I4e6c4f96f6f5097a5c637eb3dbbd7bb8b34b7d52 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7032 Autosubmit: j4m3s <james.landrein@gmail.com> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'tvix/eval/src/builtins')
-rw-r--r-- | tvix/eval/src/builtins/mod.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index 336c320e2f00..91fe27aa4695 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -134,6 +134,9 @@ fn pure_builtins() -> Vec<Builtin> { Ok(Value::List(NixList::construct(output.len(), output))) }, ), + Builtin::new("ceil", &[true], |args: Vec<Value>, _: &mut VM| { + Ok(Value::Integer(args[0].as_float()?.ceil() as i64)) + }), Builtin::new( "compareVersions", &[true, true], @@ -269,6 +272,9 @@ fn pure_builtins() -> Vec<Builtin> { .map(|list| Value::List(NixList::from(list))) .map_err(Into::into) }), + Builtin::new("floor", &[true], |args: Vec<Value>, _: &mut VM| { + Ok(Value::Integer(args[0].as_float()?.floor() as i64)) + }), Builtin::new( "foldl'", &[true, false, true], |