【发布时间】:2016-10-15 18:43:40
【问题描述】:
嗨,我正在做一个条件,如果条件为真,我只想调用一个方法,问题是我找不到如何在 C-Lisp 中创建方法的语法我是这种语言的新手,这是代码。
/* I want to create a method here which i can all anytime in my condition but I am having problem with a syntax
(void method()
(print "Invalid")
)
*/
(print "Enter number")
(setq number(read())
(cond((< 1 number) (print "Okay"))
((> 1 number) /*I want to call a method here (the invalid one)*/ )
)
【问题讨论】:
-
void应该做什么?函数见defmethoddefun的方法(没有类型重载) -
我还建议您查看条件系统。这是一个让您入门的链接gigamonkeys.com/book/…
-
Davids 的评论是关于实际的 lisp 条件,这与其他语言中的例外情况类似,但功能更强大。我发现您可能已经知道一种编程语言,也许是 C 系列语言之一。很难吸收你的第一个关于 algol 知识的口齿不清,所以最好玩绿色并立即去学习教程或书籍。
-
数字为一时会发生什么?
-
@Sywester - 同意。 OP 应该考虑像 Practical Commmon Lisp 或类似的教程。
标签: common-lisp clisp