Jump to content

  • Log In with Google      Sign In   
  • Create Account


What am I doing wrong in this Scheme statement?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Alpha_ProgDes   Crossbones+   -  Reputation: 4688

Like
0Likes
Like

Posted 14 January 2013 - 02:10 PM

(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.


Beginner in Game Development? Read here.
 
Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley
 
If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts Posted Image
 
Spoiler

Sponsor:

#2 rnlf   Members   -  Reputation: 1116

Like
1Likes
Like

Posted 14 January 2013 - 02:14 PM

I did never write a lot of scheme, but it looks to me like you have one closing parenthesis to much in line 2.


my blog (German)


#3 swiftcoder   Senior Moderators   -  Reputation: 9763

Like
0Likes
Like

Posted 14 January 2013 - 03:55 PM

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.

 

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

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, 14 January 2013 - 03:59 PM.

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS