- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Ubuntu 18.04 上使用 Racket 7.6。我创建了这个文件,hello.rkt:
#lang racket
(define (hello) 'hello-world)
(hello)
然后我调用它:
> racket hello.rkt
'hello-world
不错。接下来我尝试将代码加载到 REPL 中并使用它:
> racket -i hello.rkt
Welcome to Racket v7.6.
> (hello) ; the function is unavailable here
; hello: undefined;
; cannot reference an identifier before its definition
; in module: top-level
; [,bt for context]
> (load "hello.rkt") ; load gives no error, but ...
> (hello) ; the function is unavailable here
; hello: undefined; ...
> (require "hello.rkt") ; require gives no error ...
'hello-world ; and runs (hello), but ...
> (hello) ; the function is unavailable here
; hello: undefined; ...
> (include "hello.rkt") ; include gives no error, but ...
> (hello) ; the function is unavailable here
; hello: undefined; ...
> (enter! "hello.rkt") ; enter! gives no error, but ...
"hello.rkt"> (enter! "other.rkt") ; if I enter! another file ...
"other.rkt"> (hello) ; the hello function is unavailable here
; hello: undefined; ...
简而言之:如何加载文件并在顶层命令行 REPL 上下文中使用它们的内容?
最佳答案
根据 https://docs.racket-lang.org/guide/intro.html , 你可以通过省略 #lang
来“模仿传统的 Lisp 环境”声明和使用(load <file>)
在 REPL 中。当我从文件中删除 #lang 行时,我得到了这个交互:
> racket
Welcome to Racket 7.6.
> (load "hello.rkt")
'hello-world
> (hello)
'hello-world
该页面确实“强烈建议反对”这种做法,转而支持基于模块的代码。
关于file - 如何在命令行 Racket 的 REPL 中加载和使用 .rkt 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60917877/
我意识到“强类型”和“软类型”的定义是松散且易于解释的,但我还没有找到关于无类型 Racket (根据我的理解意味着动态类型)和类型 Racket 的明确定义。 再一次,我确定它不是那么简单和干燥,但
我来自 Java 和 Python,很难理解面向对象代码在 Racket 中的工作方式。 给定 (define food% (class object% (super-new) (i
我安装了 Sublime Text - Racket Package,但没有用。出现此错误。我该怎么办。 [Errno 2] No such file or directory: 'racke
.rkt是“常规”Racket 源代码的常规文件扩展名。在文档中,我还看到了 .rktl 和 .rkts 正在使用。什么是.rktl和 .rkts用于,还有我不知道的更多 Racket 文件扩展名吗?
假设我为具有“中心”的集合定义了一个结构体。 (struct centered-set (center elems)) 我想保证以下条件。 elems是一个集合。 center是 elems 的成员(
我想要一个函数,它接受一个字符串,由一个 python 格式的树组成,就像这样 "[0, [1, 0]]" 并输出一个可用的 Racket 列表,像这样 '(0 (1 0)) 我的第一步是将字符串转换
是否有 Racket 内置函数列表?我正在寻找类似 this one 的列表对于 python 。我似乎无法在文档中找到一个。 最佳答案 这里有一些列表: Racket文档中所有函数的索引: http
虽然 Racket 允许创建 GUI 应用程序(甚至游戏),但我想知道它是否适合与 Things 一样在视觉上发布商业应用程序或 OmniOutliner .这样的应用程序会感觉原生还是看起来像一个不
和node的npm一样,我们使用package.json来解决依赖。 我试过raco pkg,它似乎只是一种开发/发布包的方式,而不是解决外部依赖。 最佳答案 如上所述,Racket 中的 info.
我是 Racket 的新手,尽管到目前为止我已经设法使用 servlet 并让一些东西发挥作用。我现在想做的是验证一个简单的用户名/密码 POST 请求。我已经通过“web-server/formle
我正在为现场编码表演创建一个程序,为此我需要一个基本的 S 表达式代码编辑器(我输入的内容将在适当的语法上下文中评估为 Racket 代码)。 由于 DrRacket 本身是用 Racket 编写的,
和node的npm一样,我们使用package.json来解决依赖。 我试过raco pkg,它似乎只是一种开发/发布包的方式,而不是解决外部依赖。 最佳答案 如上所述,Racket 中的 info.
我正在尝试在 Racket 中编写模块元语言 mylang ,它接受将修改后的主体传递给的第二种语言,例如: (module foo mylang typed/racket body) 相当于: (m
我没有运气找到一种方法来按照我想要的方式进行这项工作,所以如果有人能提供帮助,我将不胜感激。 我想要的是能够在终端上做到这一点: > racket 然后能够输入 Racket 命令并让它们编译。像,
我来自 Java 世界,对 Racket 充满热情。 想知道类似Maven的工具在哪里。如果你不熟悉Maven,还有Scala中的SBT,Android中的gradle,Elixir中的mix等,作为
在 typed/racket 我有一个像 [(? procedure? p ) (apply p xv*)]会导致错误: Type Checker: Function has no cases in:
我是 Lisp-scheme 的新手,对整个函数范式还很陌生,我目前正在做一个任务,要求我重载一个名称相同但参数集不同的函数 racket .下面是我试图实现的一个例子: #lang racket (
有没有办法在 Racket 中获取对象的唯一标识符?例如,当我们使用 Racket 的 eq?运算符来检查两个变量是否指向同一个对象,它使用什么标识符来实现这种比较? 我正在寻找类似 python 的
当我在 Dr. Racket 或从命令行运行我的测试时,失败的测试总是在一行上。 例如, (bad (interp-t-prog (list '(class posn extends object (
我有以下代码: (plot (function sin (- pi) pi #:label "y = sin(x)")) 但是在解决 SICP 时我没有遇到这样的结构:#:label "y = sin
我是一名优秀的程序员,十分优秀!