최성준
가입: 2011년 10월 28일 올린 글: 8
|
올려짐: 2012년11월14일 14:49 주제: [HW 6-2] 테스트셋 짜깁기 |
|
|
2010년도 게시판인가에 있는 테셋을 짜깁기해서 올립니다. (* *)를 지웠다 말았다 하시면서 쓰시면 될 것 같아요.
코드: |
(*
(
(* 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 *)
*)
(*
write ((malloc 1) = (malloc true))
(* FALSE *)
*)
|
그러하군요. 6-1이 아니라 6-2군요 ㅋㅋㅋ 본의아니게 낚아서 죄송합니다 ㅋㅋㅋㅋ
최성준 가 2012년11월16일 10:19에 수정함, 총 1 번 수정됨 |
|