方案测试用例

时间:2019-03-03 22:16:32

标签: scheme

我被要求创建一个函数,该函数需要2个函数作为参数和一个整数。这些功能应该检查条件,如果满足,则结果为true或false。

这是我的代码,但是如何测试我的代码。我要在函数中输入哪些参数进行测试?我尝试了(find harmonic even? 6),但它给了我一个错误。谐波是一个将谐波的第n个数字相加并求和的函数。有人可以帮忙吗?我可以使用哪些测试用例?

(define (find sequence test n)
  (define (helper x found)
    (let ((fx (sequence x)))
      (if (test fx)
          (if (= (+ found 1) n) fx
              (helper (+ x 1) (+ found 1)))
          (helper (+ x 1) found)))) (helper 1 0))

0 个答案:

没有答案
相关问题