已知一个新运算被定义为(define (newCalc x y) (* (+ x 1) (* y 2))),问正确使用了newCalc并得到正确结果的为_____。
A. ((newCalc) (4 5)),其结果为50
B. (newCalc 4),其结果为40
C. (newCalc 4 5),其结果为50
D. (newCalc 2 3),其结果为21
查看答案
已知一个新运算被定义为(define (newCalc x y) (* (+ x 1) (+ y 1))),问(newCalc (newCalc (newCalc 1 1) 2) 3)的计算结果为_____。
A. 6
B. 13
C. 64
D. 24
已知一个运算被定义为(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)