about summary refs log tree commit diff
path: root/tvix/eval/src/builtins/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/builtins/mod.rs')
-rw-r--r--tvix/eval/src/builtins/mod.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index 4bcaaf7a00e5..527a8f8530c4 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -221,6 +221,16 @@ fn pure_builtins() -> Vec<Builtin> {
                 x.as_str()[(beg as usize)..(end as usize)].into(),
             ))
         }),
+        Builtin::new("tail", 1, |args, vm| {
+            let xs = args[0].force(vm)?.to_list()?;
+
+            if xs.len() == 0 {
+                Err(ErrorKind::TailEmptyList)
+            } else {
+                let output = xs.into_iter().skip(1).collect::<Vec<_>>();
+                Ok(Value::List(NixList::construct(output.len(), output)))
+            }
+        }),
         Builtin::new("throw", 1, |mut args, _| {
             return Err(ErrorKind::Throw(
                 args.pop().unwrap().to_str()?.as_str().to_owned(),