首页 > 其他 > 详细

elisp之函数

时间:2015-11-23 19:08:27      阅读:306      评论:0      收藏:0      [点我收藏+]
# 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


本文出自 “天道酬勤” 博客,请务必保留此出处http://lavenliu.blog.51cto.com/5060944/1716091

elisp之函数

原文:http://lavenliu.blog.51cto.com/5060944/1716091

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!