在lisp中给符号赋予负值 [英] Giving a symbol a negative value in lisp
本文介绍了在lisp中给符号赋予负值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对Lisp还是很陌生,我正在研究基本语法.我正在尝试转换:
r1 =(-b + sqrt(b ^ 2-4-* a * c))/(2 * a)
转换成Lisp格式我认为我遇到的唯一问题是,我不能大张旗鼓地将-b识别为我的符号b的负值.到目前为止,我离lisp提示符还很远:
I'm very new to lisp and I am working on basic syntax. I am trying to convert:
r1 = (-b + sqrt(b^2 - 4*a*c))/(2*a)
into a lisp format. The only problem I think I am having is that I cannot get lisp to recognize -b as the negative value of my symbol b. This is what I have so far from the lisp prompt:
[17]> (setq a 1L0)
1.0L0
[18]> (setq b -1L0)
-1.0L0
[19]> (setq c -1L0)
-1.0L0
[20]> (setq r1 (+ (/ (sqrt (- (power b 2) (* (* 4 a) c))) (* 2 a)) -b))
*** - EVAL: variable -B has no value
The following restarts are available:
USE-VALUE :R1 You may input a value to be used instead of -B.
STORE-VALUE :R2 You may input a new value for -B.
ABORT :R3 Abort main loop
推荐答案
使用
(- b)
取反b.等同于
(- 0 b)
这篇关于在lisp中给符号赋予负值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文