Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Racket in terminal?

Tags:

racket

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.

like image 780
snario Avatar asked Nov 03 '22 23:11

snario


1 Answers

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.)

like image 144
Eli Barzilay Avatar answered Nov 11 '22 02:11

Eli Barzilay