Jump to content
  • Advertisement
Sign in to follow this  
Alpha_ProgDes

What am I doing wrong in this Scheme statement?

This topic is 2159 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

(Note to Mods/Staff: Wasn't there a Functional or Lisp Prefix in the list before?)

 

(define (subtract-1 n)
  (string-append "Number is: " (number->string n))
  (cond
    [(= n 0) "All done!"]
    [else (subtract-1(- n 1))]))

I keep getting the error: define: expected only one expression for the function body, but found 1 extra part. I'm not understanding why I'm getting this.

Share this post


Link to post
Share on other sites
Advertisement

rnlf is correct - i'd advise you switch to an editor with better brace-highlighting.

 

The interpreter is seeing '(string-append "Number is: " (number->string n))' as a complete statement (because it is), with the cond expression incorrectly trailing afterwards.

 

[quote name='Alpha_ProgDes' timestamp='1358194237' post='5021553']
(Note to Mods/Staff: Wasn't there a Functional or Lisp Prefix in the list before?)[/quote]

For some reason it wasn't enabled in For Beginners (only in General/Game Programming). I have enabled both prefixes in For Beginners.

Edited by swiftcoder

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!