최종욱
가입: 2009년 9월 15일 올린 글: 84
|
올려짐: 2010년11월15일 20:58 주제: 숙제 6-1 테스트 |
|
|
..라고 하긴 민망하지만 일단 테스트를..
6-1은 비교적 쉬운 편이라 별 거 없습니다.
코드: | (
(* fibonacci *)
let rec f = fn x =>
if x = 0 then 0
else if x = 1 then 1
else f(x-1) + f(x-2)
in
write f(10)
end
) |
코드: |
(write (fn x=>x+1) 3)
|
코드: |
if (write true) = (write false) then (write 1) else (write 2)
(* result
true
false
2 *)
|
코드: |
write (let val x=1 in (write x) end)
(* result : 1 1 *)
|
코드: |
write (
let val x=read in (write x) end
)
(* result : sth sth *)
|
코드: |
let val x = read in (read x) end
(* RUNTIME ERROR *)
|
코드: |
(* PAIR *)
(let val x = (3,4) in
write x.1 + x.2
end )
(* result : 7 *)
|
코드: |
(*MALLOC, BANG *)
let val x = (malloc 3, malloc 4) in
x.1 := read; x.2 := read;
write (!x.1 + !x.2)
end
(* result : input 10 20 => output 30 *)
|
코드: |
(* a weird code *)
write ( (malloc (write read)) := malloc 1 )
(* input x, then x is printed,
but immediately RE(unprintable) is raised *)
|
6-2 는 아직 다 못 했으므로 하는대로 =3=3=3=3= _________________ Jongwook Choi
Seoul National University, School of Computer Science & Engineering
최종욱 가 2010년11월15일 21:30에 수정함, 총 1 번 수정됨 |
|