- (format nil "begin ~2% and ~2&end")
"begin
and
end "
值得注意的是,在上述例子中,format 的第一个参数为 nil 时,打印执行后返回值不出现 nil;而参数
为 t 时,打印执行后返回值出现 nil> (SETF A (READ)) 这就是所谓 Lisp 的副产品。
小惊喜:这个函数还可以直接进行数制之间的转化,不需要其他函数了,请看上面说明的第三条。
2、利用put和get函数为lisp添加一点面向对象编程。
值得注意的是lisp是一个函数式编程语言,并不是一个面向对象编程的语言,然而你还是可以利用某些函数添加面向对象的性质。
譬如赋予符号某些属性,下面有一些函数是可以用来存取符号的属性的。
get symbol property [Function]
This function returns the value of the property named property in symbol’s property list. If there is no such property, it returns nil. Thus, there is no distinction between a value of nil and the absence of the property.The name property is compared with the existing property names using eq, so any
object is a legitimate property.
See put for an example.
put symbol property value [Function]
This function puts value onto symbol’s property list under the property name property, replacing any previous property value. The put function returns value.
(put 'fly 'verb 'transitive)
)'transitive
(put 'fly 'noun '(a buzzing little bug))
) (a buzzing little bug)
(get 'fly 'verb)
) transitive
(symbol-plist 'fly)
) (verb transitive noun (a buzzing little bug))
symbol-plist symbol [Function]
This function returns the property list of symbol.
setplist函数不能用,我就不抄录了。
上面的用法,请读者自行练习和体会。
3、利用vector函数为lisp添加新的数据类型。
这个我不用介绍了,发现。链接:
4、其它可以用的一些common lisp函数:
nconc
adjoin
member-if-->相当于vl-member-if
member-if-not-->相当于vl-member-if-not
NREVERSE
concat
rassoc
等等,太多,不再一一列举。
这个是手册,大家可以从中去寻找对你也许可能有用的函数。
如果大家找到了一些有用的,不妨分享给大家。
本帖以下内容被隐藏保护;需要你回复后,才能看到!
游客,如果您要查看本帖隐藏内容请
回复