您的位置:首页 > 其它

elisp之函数

2015-11-23 18:21 405 查看
# cat /root/elisp/function.el
(defun variable_arity (a &optional b &rest c)
"This is a function which has variable arity"
(message (concat "variable a is " a))
(message (concat "variable b is " b))
(if c (message "c is not an empty list")
(message "c is an empty list")))
(message "run the fn with 1 variable")
(variable_arity "eh")
(message "run the fn with 2 variables")
(variable_arity "eh" "bee")
(message "run the fn with 3 variables")
(variable_arity "eh" "bee" "see")
(message "run the fn with 4 variables")
(variable_arity "eh" "bee" "see" "dee")
(message "run the fn with 5 variables")
(variable_arity "eh" "bee" "see" "dee" "eee")


如何在命令行执行:
# emacs --no-site-file --script /root/elisp/function.el
run the fn with 1 variable
variable a is eh
variable b is
c is an empty list
run the fn with 2 variables
variable a is eh
variable b is bee
c is an empty list
run the fn with 3 variables
variable a is eh
variable b is bee
c is not an empty list
run the fn with 4 variables
variable a is eh
variable b is bee
c is not an empty list
run the fn with 5 variables
variable a is eh
variable b is bee
c is not an empty list


本文出自 “固态U盘” 博客,请务必保留此出处http://lavenliu.blog.51cto.com/5060944/1716091
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: