试图制定一个计划程序
尝试制作一个名为 make-odd-mapper 的方案程序!它应该是一个过程,它接受一个输入,一个过程,并生成一个过程作为输出
,例如:
(定义 i4 (mlist 10 2 30 4))
(i4)
{10 2 30 4}
((make-odd-mapper!add-one) i4)
i4
{11 2 31 4}
我知道问题需要改变输入列表和 set-mcar!和 void 是分开的......有人能给我一些合理的代码行来解决这个问题吗?如果有人想知道突变......并使用它来创建一个将过程作为其输出的过程,这将很有用......
trying to make a scheme procedure called make-odd-mapper! its supposed to be a procedure that takes one input, a procedure, and produces a procedure as an output
ex:
(define i4 (mlist 10 2 30 4))
(i4)
{10 2 30 4}
((make-odd-mapper! add-one) i4)
i4
{11 2 31 4}
I know the problem needs to mutate the input list and that set-mcar! and void are apart of it......could anyone give me some reasonable lines of code to solve this? It would be useful in case anyone was wondering about mutation.....and using it to create a procedure that makes a procedure as its output....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,简单地说,所提出的问题是不可能的。原因是,如果可能的话,那么您可以有一个表达式:
这将是由部分应用程序创建的函数的函数。但是,该函数必须修改其操作数,而这只能通过宏来完成。因此,该函数的结果将是一个宏,这是不可能的,因为宏不作为值存在。然而,通过稍微改变
make-odd-mapper!
的定义,就可以做一些稍微不同的事情。在这种情况下,您将完全按照原始问题中的方式使用它,只是不要说“您”会说
“这是这样做的代码”:
Well, the problem as posed, to put it shortly, is impossible. The reason is, if it were possible, then you could have an expression:
and this would be a function of a function, created by partial application. However, this function would have to modify its operand, and this can only be done by a macro. Therefore, the result of that function would be a macro, which is impossible, because macros don't exist as values. However, by a slight change in the definition of
make-odd-mapper!
it is possible to do something slightly different. In this case, you would use it exactly as in the original question, except that instead of sayingYou would say
Here is the code that does it this way: