summaryrefslogtreecommitdiff
path: root/rust/src/lambda.rs
diff options
context:
space:
mode:
authorArnaud Bailly <arnaud.bailly@iohk.io>2024-09-25 08:15:21 +0200
committerArnaud Bailly <arnaud.bailly@iohk.io>2024-09-25 08:15:21 +0200
commitd3781941c182fdc2971bac09b33b273e46232b00 (patch)
tree2e7f5f96c66d6675c03e7e79855369694a985aa5 /rust/src/lambda.rs
parent24bc06c9d553a94306534c9d41cb632ebfd36aae (diff)
downloadlambda-nantes-d3781941c182fdc2971bac09b33b273e46232b00.tar.gz
Evaluate both side of application
Diffstat (limited to 'rust/src/lambda.rs')
-rw-r--r--rust/src/lambda.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/rust/src/lambda.rs b/rust/src/lambda.rs
index 0080f63..b05bd22 100644
--- a/rust/src/lambda.rs
+++ b/rust/src/lambda.rs
@@ -17,7 +17,7 @@ pub fn run(arg: &str) -> String {
fn interpret(arg: &Value) -> Value {
match arg {
- Value::App(l, r) => apply(&interpret(l), r),
+ Value::App(l, r) => apply(&interpret(l), &interpret(r)),
other => other.clone(),
}
}
@@ -87,4 +87,11 @@ mod lambda_test {
let value = parse("(((lam x (lam x x)) 13) 12)");
assert_eq!(Value::Num(12), interpret(&value));
}
+
+ #[test]
+ fn interpretation_applies_to_both_sides_of_application() {
+ let value = parse("((lam x x) ((lam x x) 12))");
+ assert_eq!(Value::Num(12), interpret(&value));
+ }
+
}