From 870fa672a7b7c5c872968fd428c6fe77c3e79e4d Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 6 Apr 2019 11:17:40 +0200 Subject: subst_shift in a single pass Closes #6 --- dhall_core/src/core.rs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'dhall_core') diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs index 2f15217..a9033f3 100644 --- a/dhall_core/src/core.rs +++ b/dhall_core/src/core.rs @@ -716,36 +716,32 @@ pub fn shift( } } -/// Substitute all occurrences of a variable with an expression +/// Substitute all occurrences of a variable with an expression, and +/// removes the variable from the environment by shifting the indices +/// of other variables appropriately. /// /// ```c -/// subst x C B ~ B[x := C] +/// subst_shift(x, v, e) ~ ↑(-1, x, e[x := ↑(1, x, v)]) /// ``` /// -pub fn subst( +pub fn subst_shift( var: &V