게시판 인덱스

 
 FAQFAQ   검색검색   멤버리스트멤버리스트   사용자 그룹사용자 그룹   사용자 등록하기사용자 등록하기 
 개인 정보개인 정보   비공개 메시지를 확인하려면 로그인하십시오비공개 메시지를 확인하려면 로그인하십시오   로그인로그인 

숙제 6-2 테스트?

 
이 게시판은 잠겼으므로 글을 올리거나, 답변을 하거나 수정을 할 수 없습니다   이 주제는 잠겼으므로 답변을 하거나 수정을 할 수 없습니다     게시판 인덱스 -> 4190.310 Programming Languages (Fall 2010)
이전 주제 보기 :: 다음 주제 보기  
글쓴이 메시지
최종욱



가입: 2009년 9월 15일
올린 글: 84

올리기올려짐: 2010년11월17일 21:08    주제: 숙제 6-2 테스트? 인용과 함께 답변

이것이 이 시각에 올라온 이유는 제가 딜레이를 했기 때문입니다. 오오 통재라.


요건 기본 확인용.


코드:
1


int

코드:
"We need enough time to do homework"


string

코드:
true


true

코드:
true true


error

코드:
(fn x => x) 4


int

코드:
(fn x => x) "string"


string

코드:
(fn x => x+1) "foo"


error

코드:
 1; 2; 3; 4; 5


int

코드:
 "did";  (fn you  => "implemented") "sequence "


string

코드:
 (fn x => fn y => x + y ); 3


int

코드:
 (fn x => fn y => x + "1"); 0


error

코드:

(* let *)
let val x = 1 in x end


int

코드:

let val x = 1 in (x and 1) end

error

코드:

(* sequence is not that simple *)
(let val id = (fn x => x) in id end)
;
let val identity = (fn arg => arg) in
( identity "tricky" ; identity 0 )
end


error



(* IF *)

코드:

if true then 1 else 2


int


코드:

if "sdf" then 1 else 2

error

코드:

if false then 10 else "1245"

error

코드:

fn x=>
(
    if true then
        (fn x => 3) "5"
    else x
) 10

error

코드:

(fn x=> (if true then 
   (fn x => 3) "5"  else x))
10

int


코드:

(fn x=> fn y=> if x then y else 1)
false 1

int



코드:

(fn x=> x) ; (fn x=> 2) "oop"

int


(* let rec, let nrec test *)

코드:

let val f = fn x=> "a" in
let rec
f = fn x => ( x + f(1))
in f(11) end end

int (stack overflow)

코드:

let val f = fn x=> "a" in
let val
f = fn x => ( x + f(1))
in f(11) end end

error


코드:

read + read

int

코드:

write false

bool

코드:

write read

int

코드:

 let val f = fn x=> write x in
 write 1;
 write "a";
 write true
 end
 (*ERROR !*)
 

error

코드:

 let val f = fn x=> write x in
 f 1;
 f "a";
 f true
 end
(*ERROR. NOT BOOL *)
 

error

코드:

(* wow! *)
 let val f = fn x=> write x in
 write 1; 3 end

error

코드:

 write 10
 

int

코드:

 write (write 1 + write 2)
 

int


코드:

 write (true and (write 1))
 

error

코드:

 (fn x=> (write x) + 5) 10
 (* int *)
 

int

코드:

 (fn x=> (write x) + 5) true
 (*ERROR *)
 

error

코드:

 (3, 4)
 

(int, int)

코드:

 (
 (3, (fn x=> write x) + 5),
 ((fn x=>x) + 1, "wow")
 )
 

error


코드:

( ((fn x=>x+1), (fn y=>y and false)).1 , (3,"s").2)
 

(int -> int, string)


코드:

(1, let val z = 1 in
    (fn x=> fn y=> (x+z;
    y and true))
end)

(int , (int)->((bool)->(bool)))



코드:

 let val x = malloc(3) in x end
 

loc(int)

코드:

 let val x = 1 in
 x := 7
 end
 

error

코드:

 let val x = malloc 10 in
 x := 5
 end
 

int

코드:

 let val x = malloc 10 in
 x := "ba"
 end
 

error

코드:

 let val x = malloc (1,2) in
 x.1 := 3
 end
 (*ERROR *)
 

error

코드:

 malloc (malloc (malloc read))
 

loc(loc(loc(int)))

코드:

 let val f = (fn x => malloc x) in f end
 

error

코드:

 let val f = (fn x => malloc x) in (f 3; f 4) end
 

loc(int)

코드:

let val f = (fn x => malloc x) in (f 3; f "kwangkeun yi") end

error

잠시 후에 좀 까다로운 예제들을..
_________________
Jongwook Choi
Seoul National University, School of Computer Science & Engineering
위로
사용자 정보 보기 비밀 메시지 보내기
최종욱



가입: 2009년 9월 15일
올린 글: 84

올리기올려짐: 2010년11월17일 22:59    주제: 인용과 함께 답변

코드:

 write (malloc 1)
 

error

코드:

 write (3, 10)
 

error

코드:

 write (write 1, write true)
 

error

코드:

 malloc (write 1, write true)
 

loc( (int, bool))


코드:

 let val f = (fn a => fn b => fn c => fn d => (a+c; b and d; ((a,b), (c,d)) ) ) in f  1 2 3 4  end
 

error

코드:

 let val f = (fn a => fn b => fn c => fn d => (a+c; b and d; ((a,b), (c,d)) ) ) in f 1 true 3 false  end
 

( (int, bool), (int ,bool) )

코드:

 1=2
 

bool

코드:

 1=false
 

error

코드:

 (3,4)=1
 

error

코드:

 (1,2)=(1,2)
 

error

코드:

 (malloc 1) = (malloc 2)
 

bool


코드:

 (fn x=> fn y=> (write x; write y; x=y)) 3 4
 

bool

코드:

 (* tricky WRITE test : func is int->bool, and entire is error *)

 let val func = ( fn x=> fn y=> (write x ; write(y); (x=y)) ) 2  in
     func "hello" end
 

error

코드:

 (* tricky WRITE test : func is int->bool, and NOT ERROR *)
 (* answer : ( loc(int -> bool) *)

 let val func = ( fn x=> fn y=> (write x ; write(y); (x=y))  ) 2222 in
     (malloc(func)) end

 

loc( int -> bool )


코드:

(true, fn x=> ((write x); x and true))

(bool, bool -> bool)
_________________
Jongwook Choi
Seoul National University, School of Computer Science & Engineering
위로
사용자 정보 보기 비밀 메시지 보내기
이전 글 표시:   
이 게시판은 잠겼으므로 글을 올리거나, 답변을 하거나 수정을 할 수 없습니다   이 주제는 잠겼으므로 답변을 하거나 수정을 할 수 없습니다     게시판 인덱스 -> 4190.310 Programming Languages (Fall 2010) 시간대: GMT + 9 시간(한국)
페이지 11

 
건너뛰기:  
새로운 주제를 올릴 수 없습니다
답글을 올릴 수 없습니다
주제를 수정할 수 없습니다
올린 글을 삭제할 수 없습니다
투표를 할 수 없습니다


Powered by phpBB 2.0.21-7 (Debian) © 2001, 2005 phpBB Group
Translated by kss & drssay