lisp 习题 区分非递减的列表
给出一个列表,当且仅当 所有元素不是递减的时候返回 true CL-USER> (defun not-r (lst) (if (or (null lst) (= 1 (length lst)...
求无序数组总第n大的数
微博里内容了,原文是求 无序数组中第二大的数。 实际编程实践中,不可能只求第二大,我扩展为第n 大 给出lisp 的代码: 一个基于 list 的,一个是基于数组的。 CL-USER> (defun get-nth-max (lst n)&nb...
lisp 习题 用列表元素标识文件一行。
定义一个函数,接受一个文件名并返回一个由字串组成的列表,来表示文件里的每一行CL-USER> (defun pseudo-cat (file) (with-open-file (str file :direction :input) (let ((x nil))&nb...
lisp 习题 矩阵旋转
给定一个方形矩阵 (m = n) 做顺时针90度转换:CL-USER> (turn #2a((a b)(c d)))#2A((C A) (D B))1 2 3 7 4 1 &nbs...
lisp 习题 occurrences
定义一个函数,接受一个列表并返回一个列表,指出相等元素出现的次数,并由最常见至最少见的排序:> (occurrences '(a b a d a c d c a))((A . 4) (C . 2) (D . 2) (B . 1))(defun cnt-item (item lst) ...
lisp 习题 occurrences
定义一个函数,接受一个列表并返回一个列表,指出相等元素出现的次数,并由最常见至最少见的排序:> (occurrences '(a b a d a c d c a))((A . 4) (C . 2) (D . 2) (B . 1))(defun cnt-item (item lst) ...
lisp 习题 post+
假设函数 pos+ 接受一个列表并返回把每个元素加上自己的位置的列表:> (pos+ '(7 5 1 4))(7 6 3 7)CL-USER> (defun post+ (lst) (and (listp lst) ...
lisp 习题 (member '(a) '((a) (b))) 为什么返回nil
为什么 (member '(a) '((a) (b))) 返回 nil?CL-USER> (member '(a) '((a) (b)))NILCL-USER> (member '(a) '((a) (b)):test #'equal)((A) (B))CL-USER> (member 'a '((a) (b)):key #'car)((A) (B))CL-USER> ...
lisp 习题 our-union
写一个保留原本列表中元素顺序的 union 版本: > (new-union '(a b c) '(b a d))(A B C D)CL-USER> (defun our-union (fi...
buildapp 生成独立可执行lisp程序
buildapp 是一个开源lisp项目, BSD 协议 把sbcl 的lisp 代码编译成独立可执行程序。可以把lisp 脚本编译成一个二进制的执行文件由于他需要把所有的引用到的package 都会混进去,还有sbcl 的imag 。所以出...
lisp 代码示例
非原创,抄来的: http://www.newsmth.net/nForum/#!article/FuncProgram/2185刚学lisp不久:)有些地方还不是很清楚,所以用了比较笨的办法,还请大家多多指教 //bow ;; s 开始状态 ;; 结束状态集 ...
cl 的完整程序
说明: 非原创,抄来的, 放在这里的目的是,给大家一个范例,写一个可以发布的lisp 程序基本就是这个格式了http://blog.sina.com.cn/s/blog_510ac74901011fww.html这应该还是算实用的一段代码,虽然,用python,per...
lisp 闭包
闭包: 闭包是可以包含自由(未绑定到特定对象)变量的代码块;这些变量不是在这个代码块内或者任何全局上下文中定义的,而是在定义代码块的环境中定义。“闭包” 一词来源于以下两者的结合:要执行的代码块(由于自...
lisp 支持远端debug
practical common lisp 里有一段话: An even more impressive instance of remote debugging occurred on NASA’s 1998 DeepSpace 1 mission. A half year after the space craft launched, a bit of Lisp code was...
clisp emacs slime windows 安装
WindowsInstall CLISP.Ask CLISP where the HOME directory is located: (user-homedir-pathname). In that directory, create an empty text file called .clisprc.lisp.Install Emacs.Download a CVS snapsho...