Working through Little Schemer, We're required to define a few of our own functions. I've defined them, only add1 and sub1 appear in the repl after it loads. I'm using Racket v7.0.
#lang racket
(provide atom? add1 sub1)
(define atom?
(lambda (x)
(and (not (pair? x)) (not (null? x)))))
(define add1
(lambda (x)
(+ x 1)))
(define sub1
(lambda (x)
(- x 1)))
I cannot figure out why (atom?) does not load. When I copy paste the s-expression into repl it works. Any ideas?
Since you are unsing
#lang racket
andprovide
the correct way to use the file is withrequire
.So imagine you make a program like this:
You save it and run it:
Also note that you can use R6RS and make
toys
a library. You then need to useplt-r6rs --install toys.rkt
and then use(import (rnrs base) (toys))
.