问题标签 [scheme]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
419 浏览

scheme - 为什么这段代码在 Scheme 中不起作用?

我尝试在 DrScheme 中运行它们,但它们不起作用。为什么?

0 投票
2 回答
9429 浏览

scheme - 如何使用套装!在计划函数中?

你会怎么用set!在一个简单的过程 f 中,如果 (+ (f 0) (f 1)) 的参数是从左到右计算的,那么计算 (+ (f 0) (f 1)) 将返回 0,但如果参数是从右到左计算的,则返回 1?

0 投票
8 回答
37104 浏览

ide - 适用于 Windows 的方案 IDE

什么是适用于 Windows 的好的 Scheme IDE?好吧,我承认;我没有达到 RMS 的水平,也不想使用 Emacs 或任何基于字符的界面——我想要一个具有着色功能的图形 IDE、REPL 以及针对特定的、有据可查的方言的可用内联帮助计划。我四处搜索,PLT Scheme/DrScheme 似乎是最好的,但即使这样看起来也不太复杂。

0 投票
1 回答
404 浏览

scheme - 如何清除 Scheme 中的内部列表?

我有以下代码,并想添加一条“清除消息”,从内部列表中删除所有存储的数字。我该怎么做?

0 投票
4 回答
5359 浏览

lisp - 在 Scheme 中将字符串转换为代码

如何将字符串转换为PLT Scheme中的相应代码(不包含该string->input-port方法)?例如,我想转换这个字符串:

进入这个列表:

是否可以在不打开文件的情况下执行此操作?

0 投票
2 回答
379 浏览

macros - R6RS Scheme 的 make-variable-transformer 有什么好处?

在查看syntax-caseR6RS 中的部分时,我看到了关键字make-variable-transformer,描述为标识符宏。给出的例子非常少,我不明白为什么它是必要的,或者什么用例需要它。事实证明,寻找其使用的其他示例也很困难。大概它使某种形式的语法转换成为可能,或者更优雅?

0 投票
2 回答
6112 浏览

scheme - 您将如何在 Scheme 中读取输入文件?

我正在尝试将 .txt 文件中的数据输入到方案结构中。每个元素都由数据文件中的制表符分隔,每个结构集都在新行上。我希望能够将数据从一行读入一个结构,并列出文件中设置的每个结构。有什么建议么?

0 投票
3 回答
682 浏览

scheme - 用于嵌套表达式的方案宏

可以用 Scheme 编写一个宏(define-syntax例如,使用 ),它将采用如下表达式:

并将这样的表达式作为输出?

当然,对于任意长度。给定这样的模板,我想不出办法:

0 投票
3 回答
697 浏览

c - DrScheme 中如何实现尾调用优化?

我听说蹦床是实施 TCO 的一种无效方式。DrScheme(PLAI Scheme,技术上)是如何做到的?它是否以“正确”的方式进行(即生成直接分支到尾调用的汇编代码,而不是通过堆栈和蹦床)?

0 投票
4 回答
863 浏览

python - Questions for python->scheme conversion

I currently am trying to write a Python program using scheme semantics so I can later translate it into Scheme without relying on a lot of Pythonic stuff.

I'm trying solve the sliding puzzle problem (where you have 9 slots and 8 tiles arranged in a square) using a*, depth first, and breadth first search algorithm. I did this ~11 years ago in some AI class in Lisp, but basically at the time I had no idea about lisp, I hated it with all my heart, and only in retrospect do I realize I was programming "C" in Lisp. The prof didn't help in this matter.

I have a python function which can swap two tiles easily:

I'd like to turn this into something you might find in SICP, avoiding side effects, etc.

But this brings up a question. Everything I read in SICP is loops via recursion. I didn't see anything in accessing arrays/vectors/lists in constant time. I can imagine a loopish/recursive way to read an element, but I find it harder to imagine a way to create a new list with a certain element changed, without invoking side-effect producing things like set!, and without resorting to crazy if/then/else clauses concerning which element should be changed. This of course gets more confusing when considering a 2d array. In this case the solution with python is obvious because of its native support for multidimensional arrays.

In C/C++/Python/Matlab/Lua/anything else, accessing lists/arrays via the [i] syntax is easy, and directly translates to a hardware-oriented pointer lookup somewhere underneath. I don't understand how scheme does this, given the atomic operations defined in the SICP version of scheme, which all seem very loop-and-search oriented. How do the vector and list array access functions work to get constant time access? (I'm a total newbie here, so I'm not ever sure what functions I'd be talking about). Is there a C or Assembly library someplace which is secretly being accessed? Are there any inherent constant-time semantics in scheme which could be used for list/array/vector access, and which would allow me a guilt-free way of using that idiom in Python for the moment?

How would can I rewrite the above function in python using Schemish semantics? How would I rewrite the above function in Scheme?