有没有办法在这种语言中更改变量的值? [英] Is there a way to change the values of variables in this language?

查看:46
本文介绍了有没有办法在这种语言中更改变量的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 scheme 编写一个过程,我试图操纵变量的值.我使用 define 函数为变量赋值,但我无法更改该值.我会使用 let 函数,但变量更改仅在 let 函数的主体中有效.是否有其他方法可以操作变量并能够从过程中的任何位置查看更改?

I am writing a procedure in scheme and I am trying to manipulate the values of variables. I use the define function to give a value to a variable but I can't change the value. I would have used the let function but the variable change is only effective in the body of the let function. Are there other ways to manipulate variabes and be able to view the changes from anywhere in the procedure?

谢谢

推荐答案

可以使用set! set-car! set-cdr! 在变量被定义之后

you can use set! set-car! set-cdr! after the variable has been defined

这篇关于有没有办法在这种语言中更改变量的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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