I need to run a basic Scheme script and get his output. Let's take this example :
test.scm
(define square ( lambda (x) (* x x)))
(square 3)
And when I run racket -f test.scm
, I didn't get the result of (square 3)
.
How can I run the file and get return values displayed as is the case when I wrote it in the interactive mode.
(I can run racket with -i but I don't want to call my functions each time I run the script) Thanks !
Racket and it's non Scheme language #lang racket
prints the result of all top level expressions unless it is the same object as when evaluating (void)
.
If you look at the guide you'll see that you can simply just supply the file path as an argument without swicthes:
racket test.scm # prints "9\n" and exits
And Bob's your uncle