recursion - Scheme: Why does evaluating this recursive function defined in letrec fail? -


i writing silly letrec in scheme (drracket pretty big):

(letrec     ((is-creative?        (lambda (writing)         (if (null? writing)             #f             (is-creative?               (eval writing)))))) (is-creative?   (quote is-creative?))) 

syntax check ok, running fails with:

reference undefined identifier: is-creative? 

the debugger says @ point of failure that:

is-creative? => #<procedure:is-creative?> 

can please tell me missing? correction nice well, please no defines, not necessary though.

thank you!

eval not see local variables. in scope eval running, is-creative? bound local variable but, because it's inside (letrec) , not after it, hasn't been bound in global scope yet. see documentation eval, discusses this:

http://docs.racket-lang.org/guide/eval.html

i don't think can you're trying eval. don't know reason why you're trying it, it's hard me suggest alternative. might try using (apply) instead, though.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -