snario
snario

Reputation: 473

How to use Racket in terminal?

I'm having no luck finding a way to have this work the way I'd like it to, so if anyone could help that would be so greatly appreciated.

What I'd like is to be able to do this on Terminal:

> racket

And then be able to enter Racket commands and have them compile. Like,

> (+ 1 2)
> 3

And hopefully some commands like

> racket myprog.rkt
> 3

Where myprog.rkt was just the file containing (+ 1 2).

I'm new to this so sorry if it's an obvious question but I just don't know how to make it work.

Thanks.

Upvotes: 7

Views: 13417

Answers (2)

It would a great idea to first download Racket, you can find the download file or also do it with Snap or Flathub, check it out. To complement @EliBarzilay, if you are on GNU/Linux, on a debian based system you need to install racket, running:

sudo apt install racket 

Or in RHEL/Fedora:

sudo dnf install racket

for then:

racket myprog.rkt

Upvotes: 1

Eli Barzilay
Eli Barzilay

Reputation: 29556

You're describing almost exactly what the racket executable is doing. The only difference is that your myprog.rkt would need to have a #lang racket at the top.

If you're using a Mac, you'll need to run the executable with a direct path, or add it to your environment's $PATH, or make a symlink to it. You will find the executable in the bin subdirectory.

If you're on Windows, you have to do the same -- either add the Racket directory to the PATH in the system settings, or run it directly. On windows, you should have a startup link to the Racket executable which will run in a cmd box. (And note that if you look at the Racket directory, there will not be a bin subdirectory.)

Upvotes: 4

Related Questions