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 6236155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:48:02+00:00 2026-05-24T10:48:02+00:00

After a few years of programming it seems time to finally attack SICP .

  • 0

After a few years of programming it seems time to finally attack SICP. However, instead of editing and running everything in Emacs, I’d rather use a different editor and a simple makefile to run all the exercises. This doesn’t seem to be entirely canon, because I couldn’t find any reference to something as basic as running a file until something “fails”. So how do I run Scheme on the shell so that it loads a file, evaluates each expression in sequence, and terminates with a non-zero exit code as soon as it encounters a statement which evaluates to #f or with an exit code of zero if the entire file was evaluated successfully? The closest thing to a solution so far:

$ cat ch1.scm
...
(= 1 2)
$ scheme --load ch1.scm
...
Loading "ch1.scm"... done

1 ]=>

Edit: In other words, is there some way to make evaluation stop during the loading of ch1.scm if any of the expressions therein evaluate to #f?

  • 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-05-24T10:48:03+00:00Added an answer on May 24, 2026 at 10:48 am

    One option if you don’t want to resort to a full-blown unit-testing library (understandable) is to write your own. You can use read to read s-expressions from the file, use eval to evaluate them and test if they are false, and report back, quitting if you find a false. Something like this should work:

    (define (read-and-test filename env)
      (call-with-input-file
          filename
        (lambda (in)
          (let loop ((input (read in)))
            (if (eof-object? input)
                (display "done!")
                (begin
                  (if (eval input env)
                      (begin
                        (display input)
                        (display " ok")
                        (newline)
                        (loop (read in)))
                      (begin
                        (display "failed on ")
                        (display input)
                        (newline)
                        (exit)))))))))
    

    If you put the above in a file called unit.scm and the file you want to test is called test.scm, you can call this with MIT Scheme from the Unix command line like so:

    mit-scheme --load `pwd`/unit.scm --eval '(read-and-test "/Users/aki/code/scratch/test.scm" (the-environment))'
    

    (note there’s some MIT Scheme specific things above, related to eval and enviroments)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting back into a bit more .NET after a few-years of not
I've been using Subversion for a few years and after using SourceSafe , I
After using .NET for several years, I've spent the last few months in the
After doing web development (php/js) for the last few years i thought it is
I've experience in doing desktop and web programming for a few years. I would
I'm quite new in C++ after few years in Java and eclipse, I got
I have just started web development after a few years. Mostly in the past
I've never programmed a game, but have about a dozen years programming interfaces. After
I've never programmed a game, but have about a dozen years programming interfaces. After
After a few years coding in C++, I was recently offered a job coding

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.