存储函数结果的方案(Let)

编程入门 行业动态 更新时间:2024-10-19 08:52:32
本文介绍了存储函数结果的方案(Let)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 (define [DML vara] (cond ((atom? (car vara)) (cond ((eqan? (car vara) 'N) (display (cdr vara))) (else (negate vara))) )))

为简便起见,我目前正尝试保存返回内容,我正在测试求反函数,它返回"列表,并且我想保存该函数的结果以进行测试.我如何实际保存取反的列表.有点像(x =(求反vara)),其中x是列表.我在Google和堆栈上查找let,但找不到基本的简单作业.

I'm currently trying to save the content of a return right now for simplicity I was testing the negate function it "returns" a list and I wanted to save the result of that function to do testing. How do I actually save the list return from negate. Kind of like (x = (negate vara)) where x is the list. I look up let on google and in stack over flow but I can't find a very simple basic assignment.

请原谅我在方案上的拙劣语法.从命令式语言过渡到功能并不顺利.

Excuse my poor syntax on scheme I'm just starting..and going from imperative language to function isn't so smooth..

我想打印出(negate vara)的结果表达式,但是由于scheme仅打印出了最后一个递归调用"(请原谅我的措辞不好).我希望它使用来自(求和vara)的结果列表,但仍打印出该列表,例如

I wanted to print out the result expression of (negate vara) but since scheme only prints out the last "recursive call" (pardon my bad wording). I wanted it to use the resulting list from (negate vara) but still print out that list like

say if I had (else (test (negate vara))) ... (define (test vara) (display "test") ) I wanted it to display '(O a b)) ;list here

推荐答案

您可以按照建议的步骤进行操作:

You could make a procedure like you proposed:

(define (test var) (display var) var) (test (negate (test vara)))) ; prints our argument and return

或者您可以使用DrRacket并使用调试器.使用一次后,您将错过它!

Or you could use DrRacket and use the debugger. You'll miss it after using it once!

更多推荐

存储函数结果的方案(Let)

本文发布于:2023-10-26 18:45:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1531029.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   方案

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!