Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9138629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:16:54+00:00 2026-06-17T09:16:54+00:00

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

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

NOTE TO SELF: When using DrRacket, Setting the language to BSL may make Racket commands error at compile time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:16:54+00:00Added an answer on June 17, 2026 at 9:16 am

    The language you’re using (BSL) only allows a single expression inside the body of a procedure, if there’s more than one expression, you need to pack them inside a begin.

    Also notice that the string-append line is doing nothing, you should print it or accumulate it. Here’s a possible solution with my recommendations in place:

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

    Even better, use the printf procedure for simplicity’s sake:

    (define (subtract-1 n)
      (begin
        (printf "~a ~s~n" "Number is:" n)
        (cond
          [(= n 0) "All done!"]
          [else (subtract-1 (- n 1))])))
    

    Either way a sample execution looks like this:

    (subtract-1 3)
    => Number is: 3
    => Number is: 2
    => Number is: 1
    => Number is: 0
    => "All done!"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Concrete Abstractions , there is this example of recursion: (define subtract-the-first (lambda (n)
I define a 'block' of text as all lines between start of file, newline
I have the following line in code: #define INACTIVITYTIMEBEFOREBAITARROWDISPATCHED 60.0 I get an error
The compiler gives me an error when trying to subtract two Point3D objects. I
I need to subtract two date fields in order to get the number of
I wrote a program out, which was all in one file, and the methods
#define BUF_SIZE 10 char *html = foo:baa\r\nxxx:yyyy:\r\nLocation:........................................\r\Connection:close\r\n\r\n; char *p = (char*)html, *buf, *pbuf, *tbuf;
(define (lcs lst1 lst2) (define (except-last-pair list) (if (pair? (cdr list)) (cons (car list)
#define MAX 100 struct bs{ int ab; int ac; }be; struct s{ be b;
#define HISTORY_SIZE 50 #define INPUT_SIZE 512 /*Max input size*/ char input[INPUT_SIZE]; /*Holding user input

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.