[plt-scheme] Internal definitions error. - Beginner.
Hi,
I seem to be getting this error:
define: expected only one expression for the function body, but found
at least one extra part
When trying to use internal definitions such as:
(define (f n)
(define (f-w-counter n c)
(cond
((< n 3) n)
(else (* c (f-w-counter (- n 1) (- c 1))))))
(f-w-counter n 1))
or
(define (sqrt2 x)
(define (good-enough? guess x)
(< (abs (- (square guess) x)) 0.001))
(define (improve guess x)
(average guess (/ x guess)))
(define (sqrt-iter guess x)
(if (good-enough? guess x)
guess
(sqrt-iter (improve guess x) x)))
(sqrt-iter 1.0 x))
the latter is not mine, but from Structure and Interpretation of
Computer Programs - 1.1 The Elements of Programming. I'm not too sure
where I'm going wrong here, I understand it's something pretty basic,
but haven't managed to find an answer in the documents or PLT Scheme /
HTDP newsgroups. I've tried turning the language setting all the way
up to 11- advanced student, but no dice. I understand the error,
there's 2 expressions within the definition, but I can't see why
that's a problem.
Any help would be greatly appreciated. I understand I don't need to
use an internal definition for what I'm doing, but it would be good to
know where my confusion lies.