# SICP 1.3.2 Constructing Procedures Using LambdaをPythonでやってみた

##### scheme
```(define (square x)(* x x))
;a
(define (f x y)
(define (f-helper a b)
(+ (* x (square a))
(* y b)
(* a b)))
(f-helper (+ 1 (* x y))
(- 1 y)))
(f 1 4) ;4
;b
(define (f x y)
((lambda (a b)
(+ (* x (square a))
(* y b)
(* a b)))
(+ 1 (* x y))
(- 1 y)))
(f 1 2) ;4
;c
(define (f x y)
(let ((a (+ 1 (* x y)))
(b (- 1 y)))
(+ (* x (square a))
(* y b)
(* a b))))
(f 1 2) ;4
;d
(define (f x y)
(define a (+ 1 (* x y)))
(define b (- 1 y))
(+ (* x (square a))
(* y b)
(* a b)))
(f 1 2) ;4
```
##### python
```#a
def f_a(x,y):
def f_helper(a,b):
return (x * (a ** 2)) + (y * b) + (a * b)
return f_helper((1 + x * y), (1 - y))
print f_a(1,2) #4
#b
def f_b(x,y):
la_helper = lambda a,b:(x * (a ** 2)) + (y * b) + (a * b)
return la_helper((1 + x * y), (1 - y))
print f_b(1,2) #4
#c
def f_c(x,y):                   # pythonでletの代用って？
a = 1 + x * y
b = 1 - y
return (x * (a ** 2)) + (y * b) + (a * b)
print f_c(1,2) #4
#d
def f_d(x,y):
def a():
return 1 + x * y
def b():
return 1 - y
a = a()
b = b()
return (x * (a ** 2)) + (y * b) + (a * b)
print f_d(1,2) #4
```