附加字符串和变量
你好在我的代码中的某些地方,我想打印出附加到字符串的veriable的值,例如
如何?
谢谢
谢伊 我已经使用LISP很久了,但我认为您需要STRCAT(字符串连接) STRCAT为1+
这里使用的“+”运算符适用于C#(可能也适用于ARX?),例如,这是用LISP编写的:
(setq foo "Bowties")
(princ (strcat "\n** " foo " are cool ** "))
... 用C#写成:
string foo = "Bowties";
ed.WriteMessage("\n** " + foo + " are cool ** ");
... 或作为:
string foo = "Bowties";
ed.WriteMessage("\n** {0} are cool ** ", foo);
(princ (strcat "\nThe value of dx is " (vl-princ-to-string dx))) 看起来我需要一个效用函数。。。
致龙
用法(注意引号):
_$ (setq a 2 b "ABC" c '(1 2 3))
(1 2 3)
_$ (princ_val 'a)
The value of A is 2
_$ (princ_val 'b)
The value of B is ABC
_$ (princ_val 'c)
The value of C is (1 2 3)
_$ (princ_val 'd)
The value of D is nil
_$ 或:
(defun _prin1 ( *sym* )
(print *sym*)
(princ "= ")
(prin1 (eval *sym*))
(princ)
)
斯特凡,小心(普林斯)
针对OP的问题:
(princ "\nThe value of dx is: ")
(prin1 dx)
啊,是的,当然,我肯定我以前试过这样的东西,但我忘记了这个问题。 这里不可以使用mapcar吗?
(mapcar 'princ '(“the value of dx is: ” dx))或作为公用设施
这里我不会讨论代码的长度,但我要说的是,当你有一个很长的列表时,波兰语符号非常有用。
好的,我还要注意,代码的长度可能与程序员的能力有很大关系。如果你环顾四周,你可能会发现最好的程序员通常拥有最短的代码,但你可能比初学者的更长代码更难破译它。
它可以,但它是多余的,因为您构建列表的唯一目的是能够使用mapcar,并且mapcar返回的结果列表也不会被使用。
12,与之相反:
13
页:
[1]
2