I would like to create a library with my own factorial, in order to call it when I need it without writing again or copying again the code.
How should I save it, and how do I have to import it where I will need it (compiler lines such import / provide)?
EmEf
2
-
Save as factorial.rkt.
-
Add (provide factorial)
-
Use (require factorial)
(But I notice that there’s no language specified. Are you using the Teaching languages?)
1 Like
The (require factorial)
would only work if it's main.rkt
in a factorial
collection. If it's not part of a collection, (require "factorial.rkt")
works in the same directory. More at https://docs.racket-lang.org/guide/module-paths.html (Guide).
1 Like
I would like to start putting the file providing the factorial in the same folder where the program that requires has its place.
Here is the result

Both files saved as indicated. Error persists.
EmEf
6
(require “factorial.rkt”)
1 Like