I am trying to calculate how combination nCk using memoization in racket/scheme
I can't use separate recursive method to calculate n!. I have done this far, but saying this is bad syntex i actually fixed bad syntex error! but still gets an error in (let ([ans (assoc (x y) memo part!. anyone know what i have done wrong?
(define combm
(letrec ([memo null]
[f (lambda (x y)
(let ([ans (assoc (x y) memo)])
(if ans
(cdr ans)
(let ([new-ans (letrec ([fac (lambda (x)
(if (eq? x 0)
1
(* x (fac (- x 1)))))])
(/ (fac x) (* (fac y) (fac (- x y)))))])
(begin
(set! memo (cons (cons (x y) new-ans) memo))
new-ans)))))])
f))
`