recursion - Unbound variable in edwin scheme -


i'm learning scheme first time, , practice i'm trying write program returns list of specified length values equal 1. i'm using mit/gnu edwin editor on windows 10. here's code typed:

(define (listlength n)   (if (= n 1)       (list 1)       (append (list 1) (listlength (- n 1)))))  (listlength 5) 

i hope c-x c-e return (1 1 1 1 1), instead unbound variable error:

;unbound variable: listlength ;to continue, call restart option number: ;  (restart 3) => specify value use instead of listlength. ;  (restart 2) => define listlength given value. ;  (restart 1) => return read-eval-print level 1. ;start debugger? (y or n): 

the reason can think of doesn't me calling listlength in definition of listlength, that's supposed part of makes scheme scheme, so??? i'm @ loss?? can give me!

you should check if use c-x c-e @ end of function. c-x c-e evaluate expression @ left of cursor. or can use m-z ,which evaluate whole expression not matter cursor. beginner of scheme, , hope answer can you!


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -