Expected module announcement, found something else?

I am working on a Racket script (on a Linux machine) that requires a math library and number theory. My whole script at the moment is this:

#!/usr/bin/racket (require math/number-theory) 

Yes, it literally just requires a library.

When I try to start it, I get the error "expected module declaration": something else ".

However, when I actually run Racket in a terminal, for example:

 /usr/bin/racket 

and enter (require math / number theory) on the command line, it treats it as completely valid.

What's going on here?

+7
racket
source share
1 answer

Make sure the top of your racquet files contains the #lang operator.

In other words, this is needed at the top of the file:

 #!/usr/bin/racket #lang racket 
+6
source share

All Articles