Skip to content

Instantly share code, notes, and snippets.

@kaikai2
Last active December 13, 2015 21:28
Show Gist options
  • Save kaikai2/4977656 to your computer and use it in GitHub Desktop.
Save kaikai2/4977656 to your computer and use it in GitHub Desktop.
; http://acl.readthedocs.org/en/latest/zhCN/ch5-cn.html#chapter-5-exercises
; 5.7-c
; 定义一个接受一系列数字的函数,并在若且唯若每一对(pair)数字的差为一时,返回真,使用mapc 与 return。
(defun linked-mapc (lst)
(mapc #'(lambda (x y)
(unless (diff-1 x y)
(return-from linked-mapc nil)))
lst (cdr lst))
t)
(defun diff-1 (a b)
(or (eql a (+ b 1))
(eql b (+ a 1))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment