如何从球拍中的文件导入函数? [英] How can I import a function from a file in racket?

查看:37
本文介绍了如何从球拍中的文件导入函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定这是一个非常基本的问题,但我有两个文件,我想将一个函数从该文件导入另一个.有办法吗?

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?

推荐答案

您可以在模块中使用 provide 将定义导出到使用 require 导入它的其他模块:

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

有关详细信息,请参阅文档.

这篇关于如何从球拍中的文件导入函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆