"let"에 기능 추가하기
HNU CE 프로그래밍언어론 (2021년 1학기)
클로저(closure)
let x1 = 1 in
let x2 = 2 + x1 in
let x3 = 3 + x2 + x1 in
x1 + x2 + x3
let x1 = 1 ;
x2 = 2 + x1 ;
x3 = 3 + x2 + x1 in
x1 + x2 + x3
let sum_upto = \x. if x < 1
then 0
else x + sum_upto (x + (-1))
in
sum_upto 10
귀찮게 매번 fixpoint 컴비네이터 쓰지 않고도
let even = \x. if x=0 then true else odd (x + -1)
; odd = \x. if x=1 then true else even (x + -1)
in
even 10
같은 let안에서 정의된 이름이면
순서에 관계없이 서로 불러 쓸 수 있도록