“application: not a procedure” while computing binomial

后端 未结 3 486
别跟我提以往
别跟我提以往 2021-01-26 15:09

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条回答
  •  悲哀的现实
    2021-01-26 16:06

    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))
    

提交回复
热议问题