“application: not a procedure” while computing binomial

后端 未结 3 1273

I am defining a function binomial(n k) (aka Pascal\'s triangle) but am getting an error:

    application: not a procedure;
    expected a procedure          


        
3条回答
  •  闹比i
    闹比i (楼主)
    2021-01-26 15:43

    This is the correct code:

     (define (binomial n k)
              (cond  ((or (= n 0) (= n k)) 1)
                  (else (+ (binomial n (- k 1))(binomial(- n 1) (- k 1)))))) 
    

    Problem is at here:

    (binomial (n) (- k 1))
    

提交回复
热议问题