次のように定義された関数length (ソース):
struct _list {
int car;
struct _list* cdr;
};
typedef struct _list* list;
list cons(int x, list xs) {
list ret = (list)malloc(sizeof(struct _list));
ret->car = x;
ret->cdr = xs;
return ret;
}
int length(list xs) {
if (xs==NULL) {
return 0;
} else {
return 1+length(xs->cdr);
}
}
を同等な繰り返しを用いた定義に書き換えよ。
プリントp.46 問5.7.1
このHTMLファイルを元にしてよい。
締切は2月13日、提出場所は学務係のレポートボックスです。