0
votes
(define (rec base height)
  (let ((product (* base height))(half 0.5))
   (let ((sum (* product half)))
     (display "Area is")
     (display sum))))


let: expected only one expression after the name-defining sequence, but found one extra part in: (display sum)

I am having the error as above, I don't know which part goes wrong

2

2 Answers

3
votes

In full Scheme, this is allowed. However, you are probably using one of the teaching variants of Scheme (such as Intermediate Student or Advanced Student) that Racket provides, which disallows functions with more than one expression.

I'd say you can work around it by using begin, but Intermediate Student doesn't provide begin either (Advanced Student appears to, which helps). If you're using Intermediate Student, I guess you're just not meant to use multiple expressions, and that's that. :-)

0
votes

The beginning and intermediate student languages really aren't a good fit for programs that use I/O. If your teacher is assigning problems that require you to use one of these languages and also require you to print something out, that would be a somewhat inappropriate assignment.

For the record, I certainly make mistakes like this myself....