已知一个新运算被定义为(define (newCalc x y) (* (+ x 1) (+ y 1))),问(newCalc (newCalc (newCalc 1 1) 2) 3)的计算结果为_____。
查看答案
已知一个运算被定义为(define (firstCalc x) (* x x)),在其基础上进一步定义新运算secondCalc为x2+y2+z2,下列运算组合式书写正确的是_____。
A. (define secondCalc (+ (firstCalc x) (firstCalc y) (firstCalc z)))
B. (define (secondCalc x y z) (+ firstCalc x y z))
C. (define (secondCalc x y z) (+ (firstCalc x) (firstCalc y) (firstCalc z)))
D. (define secondCalc x y z (+ (firstCalc x) (firstCalc y) (firstCalc z)))
若要表达从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