clisp: variable has no value

青春壹個敷衍的年華 提交于 2019-12-25 00:13:06

问题


I want to make user-program which extract elements a which have element b (given by parameter) as pair in list.

Like, if I give c as parameter and list ((c a) (c b) (d f) (d g)), result should be 'a' 'b';

So I define a function as below,

(defun myr (b a) (if (= CAAR(a) b) CDAR(a) 'nope myr(b CDR(a))));

and call like this

myr(b ((b a) (b c) (a d) (a f)))

But result is like variable myr has no value

Its my first time in Lisp, So just tell me what keyword should I search for will be great help for me.

Thank you for reading.


回答1:


You really need to start with a good lisp book, e.g., PCL or ACL. You will save yourself a lot of time.

Lisp syntax is different from C. In C, you call a function f with arguments х and y like this: f(x,y). In Lisp, you do it like this: (f x y).

When you invoke your function myr(...), you put the symbol myr in the variable position, not function position, which causes the error you reported.

You also need to use quote as appropriate.



来源:https://stackoverflow.com/questions/56208001/clisp-variable-has-no-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!