The let form binds the names in series, so in the second function definition, the name l does not exist when you try to access it. You can use letfn (with some minor modifications) or give a specific function a name and refer to it instead, for example:
(def leven (let [l (memoize (fn SOME-NAME [xy] (cond (empty? x) (count y) (empty? y) (count x) :else (min (+ (SOME-NAME (rest x) y) 1) (+ (SOME-NAME x (rest y)) 1) (+ (SOME-NAME (rest x) (rest y)) (if (= (first x) (first y)) 0 1))))))] l))
As you may have noticed, I am changing the return from let to l , since that is what you want to bind leven . (lxy) was problematic because it only referenced bindings locally to a function and was not accessible to let .
fogus
source share