由买买提看人间百态

topics

全部话题 - 话题: funcall
(共0页)
r*********s
发帖数: 2157
1
我用下面的, 然后 C-c o 交换两个windows
;; transpose(interchange) two windows
(defun his-transpose-windows (arg)
"Transpose the buffers shown in two windows."
(interactive "p")
(let ((selector (if (>= arg 0) 'next-window 'previous-window)))
(while (/= arg 0)
(let ((this-win (window-buffer))
(next-win (window-buffer (funcall selector))))
(set-window-buffer (selected-window) next-win)
(set-window-buffer (funcall selector) this-win)
(select-window (funcall selector)))
(setq arg (if (plusp arg) (1- arg) (1+ arg
a*******e
发帖数: 14
2
来自主题: Programming版 - Python擂台:算24点
写了个 Common Lisp 的解法,就十几行(Lisp 算子有联结到对应说明,很好理解):
http://paste.lisp.org/+2V0T
(defun twenty-four (numbers &optional (target 24) all)
"Show arithmetic expression(s), composed of the given NUMBERS and the
four basic arithmetic operators, that evaluates to the TARGET number."
(labels ((fa (x)
(if (cdr x)
(loop for (i . u) on x thereis (fb i u p) collect i into p)
(and (= target (caar x)) (print (cdar x)) (not all))))
(fb (i u p)
... 阅读全帖
a*******e
发帖数: 14
3
来自主题: Programming版 - Python擂台:算24点
写了个 Common Lisp 的解法,就十几行(Lisp 算子有联结到对应说明,很好理解):
http://paste.lisp.org/+2V0T
(defun twenty-four (numbers &optional (target 24) all)
"Show arithmetic expression(s), composed of the given NUMBERS and the
four basic arithmetic operators, that evaluates to the TARGET number."
(labels ((fa (x)
(if (cdr x)
(loop for (i . u) on x thereis (fb i u p) collect i into p)
(and (= target (caar x)) (print (cdar x)) (not all))))
(fb (i u p)
... 阅读全帖
(共0页)