How can I import a function from a file in racket?

对着背影说爱祢 提交于 2019-12-24 16:39:50

问题


I'm sure this is am extremely basic question, but I have two files and I want to import one function from that file into the other one. Is there a way to do so?


回答1:


You can use provide within a module to export definitions to other modules that import it with require:

;; a.rkt
(provide f)
(define (f x)
  (displayln (add1 x)))

;; b.rkt
(require "a.rkt")
(f 3) ; => 4

For more information, see the docs.



来源:https://stackoverflow.com/questions/34756477/how-can-i-import-a-function-from-a-file-in-racket

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!