Seblog
fun make_counter(init:int) = let val count = ref init; fun counter(inc:int) =(count = !count +inc; !count) in counter end val c = make_counter(1); c(2) + c(2) = ?
The reason is that [the term] “closure” only makes sense in a particular historical context, where procedures had previously been left “open”, that is with free variables not associated with any particular binding. This was the case in various pre-Scheme Lisps, and lead to what was known as the “funarg problem,” short for “functional argument”, though it also was manifested when procedures were ..
# 알고리즘 분석 1. Big O의 정의를 이용해 증명하는 문제 2. Quick Sort를 순차대로 써나가는 문제 3. 크기를 모르는 일차원 배열 search 문제 4. 행렬곱 문제 5. Optimal Binary Search Tree 문제 6. 동전 갯수 DP Sol> 3. 배열의 끝을 모르므로 무한대가 나올때 까지 인덱스를 두배씩 늘려가며 앞쪽에 정렬된 데이터의 경계를 찾는다. 이 후 Binary Search를 이용하여 x를 검색하는 알고리즘을 탐색한다. 6. 1) Principle of Optimality가 적용되는지 알려면 어떤게 Optimal인지 알아야함 ex> 500, 100, 50, 10, 5, 1 동전을 이용해 950원을 만들려면 500*1 + 100*4 + 50*1 이 optimal 하다..
알고리즘의 실행시간이 반복문을 사용하는 반복적 알고리즘에 비해 더 많이 걸림. 이유는 컴파일러에서 함수가 호출될 때 마다. 지역변수와 매개변수 등의 정보를 stack에 저장하는데 이를 위한 시간이 많이 걸리기 때문.