| 이전 주제 보기 :: 다음 주제 보기 |
| 글쓴이 |
메시지 |
송원욱
가입: 2014년 10월 3일 올린 글: 6
|
올려짐: 2014년10월19일 17:34 주제: A question for 3-1 |
|
|
In your previous answer, you have mentioned about type-checking like:
{= : int * int -> bool}
{* : int * int -> int}
{- : int * int -> int}
{(define (fac {n : int})
{(if {(= {n : int} {0 : int}) : bool}
{1 : int}
{(* {n : int}
{(fac {(- {n:int} {1:int}) : int}) : int}
) : int}
) : int}
) : int -> int}
However, I find this method quite inefficient and tedious due to all the repetitions. (For example, in the fac function, {n:int} is mentioned numerous times, and even {0:int} is mentioned even though it is clear that '0' is int by itself.)
Doing hw3-1 this way, I find it very inefficient for myself and for everyone else.
Or can I do it another way:
(define (foo n) // foo: int -> int list, n: int
(if (= n 0) ()
(let ((rest (foo (- n 1)))) // rest: int list
(cons n rest))))
This seems much efficient and still performing all the type-checking jobs that you require us to do.
Do we really have to do all these repetitions and mention all these self-evident types? - or at least, do we really have to do all these trivial repetitions?
송원욱 가 2014년10월19일 18:07에 수정함, 총 3 번 수정됨 |
|
| 위로 |
|
 |
이성환
가입: 2014년 9월 9일 올린 글: 34
|
|
| 위로 |
|
 |
송원욱
가입: 2014년 10월 3일 올린 글: 6
|
올려짐: 2014년10월19일 17:43 주제: |
|
|
I'm sorry, but this doesn't answer my question.
|
|
| 위로 |
|
 |
김윤승
가입: 2014년 9월 1일 올린 글: 452 위치: 302동 312-2호
|
올려짐: 2014년10월19일 18:10 주제: |
|
|
두 번째로 하신 것은 모든 타입체킹을 다 하는 것은 아니고, 모든 타입을 유추하기에 충분한 정보를 제시한 정도로 보입니다.
타입체킹 하나하나 하는 것은 지루한 일 맞습니다.
보조함수 내부까지 하나하나 할 필요는 없구요,
한 번 했던 상수나 함수를 다시 하실 필요도 없습니다.
그래도 지루하겠지만 그게 과제니까 어쩔 수 없죠.
타입체킹 문제는 완벽하게 안 해도 점수는 잘 드리고 있습니다. |
|
| 위로 |
|
 |
|