# 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
原文地址:http://lavenliu.blog.51cto.com/5060944/1716091