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

  • Home
  • SEARCH
  • 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 8714863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:42:22+00:00 2026-06-13T05:42:22+00:00

I have a program written to compute derivatives of expressions in list form so

  • 0

I have a program written to compute derivatives of expressions in list form so 4x^3 is represented as (* 4 (expt x 3)) and I am writing a test-suite to print out results. I have a function runtest that takes an expression and computes the derivative with respect to x and returns the results

(define (runtest test)
  (display "diff x ")(display test)(display " => ")(display (diff 'x test)))

so that the results display diff x expression => result

I have the following defined as tests:

(define test1 '4)
(define test2 '(* 2 x))
(define test3 '(* 2 y))
(define test4 '(+ x (* x x)))
(define test5 '(expt x 4))

and then I put all of the tests in a list so I could map over the list and return the results:

(define test-suite (list test1 test2 test3 test4 test5))

and when I run (map runtest test-suite) instead of returning each separately I get a long list with no line breaks when instead I want:

diff x 4 => 0
diff x '(* 2 x) => '(+ (* 0 x) (* 2 1))
diff x '(* 2 y) => '(+ (* 0 y) (* 2 0))
diff x '(+ x (* x x)) => '(+ 1 (* 2 x))
diff x '(expt x 4) => '(* 4 (expt x 3))

what am I missing?

  • 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-13T05:42:23+00:00Added an answer on June 13, 2026 at 5:42 am

    I think you’re looking for newline:

    (define (runtest test)
      (display "diff x ")
      (display test)
      (display " => ")
      (display (diff 'x test))
      (newline))
    

    BTW, there’s seldom a good reason to call display on anything but a string; I would recommend using write for test and (diff 'x test).

    A more idiomatic way to write it in Racket is this:

    (define (runtest test)
      (printf "diff x ~s => ~s\n" test (diff 'x test)))
    

    or, in any Scheme with SRFI-28, this:

    (define (runtest test)
      (display (format "diff x ~s => ~s~%" test (diff 'x test)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a program on 1 PC, and tested out very carefully, everything
I am writing an Android App, and already have a working program written in
I have written a Hadoop map-reduce program and now I want to test it
I have written a test program to see that my pressure sensor is working
I have program written in C. It takes 2 arguments username/password and try to
I Have a program written in VB6 that reads a long text file and
I have my program written in C++ and it is can be successfully compiled
I have a program written in C++, on Linux, compiled with -g. When I
I have a program written in VB.Net (Visual Studio 2008) that uses a DLL
I have a program written in C using ncurses. It let user input and

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.