Racket, include, require and provide don't work
Asked Answered
T

1

2

I have a file with the name “functions.rkt”, where I have some functions.

And I am working in another file, let’s name it “working.rkt”

I have tried the following (one by one) at “working.rkt” to use the function defined at “functions.rkt”:

(require “functions.rkt”)

(include “functions.rkt”)

(provide “functions.rkt”)

And anyone of them hasn’t worked, any help?

They are in the same path.

Tessatessellate answered 18/4, 2017 at 11:20 Comment(3)
Possible duplicate of Including an external file in racketConformity
Maybe you are missing line 1 or 2: 1. #lang racket 2. (require racket/include) 3. (include "functions.rkt")Conformity
This is file "funcitons.rkt": #lang racket (define (my-add x y) (+ x y)) And this is "working.rkt": #lang racket (require racket/include) (include "functions.rkt"). Then, I can't use "my-add" at "working.rkt"Tessatessellate
H
3

In the file "functions.rkt:

#lang racket
(provide my-function)
(define (my-function x) (* 2 x))

In the file "working.rkt":

#lang racket
(require "functions.rkt")
(my-function 21)
Humber answered 18/4, 2017 at 18:4 Comment(3)
Perfect!! Now is working properly. Thank you very muchTessatessellate
is there any way to "provide" access to all the functions within a file without explictly writing each name?Coffelt
(provide (all-defined-out))Humber

© 2022 - 2024 — McMap. All rights reserved.