From 4b93ca127c43aa431f2f052dcc6d7b7fa099cad7 Mon Sep 17 00:00:00 2001 From: CLRT19 Date: Thu, 11 Jan 2024 01:31:56 -0600 Subject: [PATCH] Provide a cleaner and more insightful answer --- hws/hw02/hw02.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/hws/hw02/hw02.py b/hws/hw02/hw02.py index 70aad92..9c9295f 100644 --- a/hws/hw02/hw02.py +++ b/hws/hw02/hw02.py @@ -189,11 +189,14 @@ def mul_church(m, n): 12 """ "*** YOUR CODE HERE ***" - ans = zero - int_n = church_to_int(n) - for i in range(int_n): - ans = add_church(ans, m) - return ans + # ans = zero + # int_n = church_to_int(n) + # for i in range(int_n): + # ans = add_church(ans, m) + # return ans + def temp(x): + return n(m(x)) + return temp def pow_church(m, n): """Return the Church numeral m ** n, for Church numerals m and n. @@ -204,10 +207,14 @@ def pow_church(m, n): 9 """ "*** YOUR CODE HERE ***" - ans = one - int_n = church_to_int(n) - for i in range(int_n): - ans = mul_church(ans, m) - return ans + # ans = one + # int_n = church_to_int(n) + # for i in range(int_n): + # ans = mul_church(ans, m) + # return ans + def temp(x): + return n(m)(x) + return temp +