若要表达从1计算到n的运算组合式,(* …(* (* (* (* 1 1) 2) 3) 4) …n)定义一个过程。正确的定义为_____。
A. (define (f product counter max-count) (f (* counter product) (+ counter 1) max-count ))
B. (define (f product counter max-count) (cond ((> counter max-count) product) ((<= counter max-count) (f (counter*product) (counter+ 1) max-count )) ))
C. (define (f product counter max-count) (cond ((> counter max-count) product)((<= counter max-count) (f (* counter product) (+ counter 1) max-count )) ))
D. (define (f product counter max-count) (cond ((> counter max-count) product) ((<= counter max-count) (f product counter max-count )) ))
查看答案
按原始递归的定义,h是由f和g递归地构造出来的,h(0,x) = f(x), 且h(S(n), x) = g(h(n,x),n,x)。假设已知h(n) = n!,请给出构造h的f和g的函数。正确的是_____。
A. f()是常数为1的函数;g(x1,x2) = x1* x2
B. f()是常数为1的函数;g(x1,x2) = x1* (x2+1)
C. f()是常数为1的函数;g(x1,x2) = (x1+1)*(x2+1)
D. f()是常数为1的函数;g(x1) = n * (x1)
已知f(x)=x,g(x1,x2,x3)=x1+x2+x3, 其中x,x1,x2,x3均为自然数,新函数h可递归的构造如下:h(0,x) = f(x), 且h(S(n), x) = g(h(n,x),n,x),请按递归式进行计算下列式子,正确的是_____。
A. h(1,x) = x
B. h(2,x) = 2x
C. h(3,x) = 3x+1
D. h(4,x) = 5x+6
已知f(x)=5,g(x1,x2,x3)=x1, 其中x,x1,x2,x3均为自然数,新函数h可递归的构造如下:h(0,x) = f(x), 且h(S(n), x) = g(h(n,x),n,x),请按递归式进行计算下列式子,正确的是_____。
A. h(1,x) = 5
B. h(2,x) = 5+x
C. h(3,x) = 5+2x
D. h(4,x) = 5+3x
用递归是可以定义语言的。如表述命题逻辑的一种语言可以如下定义:(1)一个命题是其值为真或假的一个判断语句;(2)如果X是一个命题,Y也是一个命题,则X and Y,X or Y, not X也是一个命题;(3)如果X是一个命题,则(X)也是一个命题,括号内的命题运算优先;(4)命题由以上方式构造。若X,Y,Z,M等均是一个命题,问不符合上述递归定义的语句是_____。
A. X
B. ( X and Y not Z)
C. (X)
D. ((X and Y) or (not Z)) and (not M)