lisp

How to make a Lisp function call java while being aware of packages?

丶灬走出姿态 提交于 2019-12-07 12:33:52
问题 In Emacs use a Lisp function to run the Java program the current file correspond to. (defun java-run-current-file () "Runs the java program the current file correspond to" (interactive) (shell-command (concat "java " (file-name-sans-extension (file-name-nondirectory (buffer-file-name)))))) It works by stripping the current file name of its path and extension and using it as an argument to java which is run from the path where the file is at. The problem with this approach is that if the

lisp sort list via function

送分小仙女□ 提交于 2019-12-07 10:07:27
问题 I am trying to use lisp's sort to sort a list via a function but dont have a clue how to do this. I have a start-point in 2D Space with x and y coordinates. Then i have a List of N-other points and i have a function that calculates the distance between 2 points. What I want now is a list, that contains all the N-Points and is sorted by distance ascending from the start-point to all other points. I think I can use the sort-function and pass a function as argument (the calculate-distance

fixed point combinator in lisp

纵饮孤独 提交于 2019-12-07 09:10:57
问题 ;; compute the max of a list of integers (define Y (lambda (w) ((lambda (f) (f f)) (lambda (f) (w (lambda (x) ((f f) x))))))) ((Y (lambda (max) (lambda (l) (cond ((null? l) -1) ((> (car l) (max (cdr l))) (car l)) (else (max (cdr l))))))) '(1 2 3 4 5)) I wish to understand this construction. Can somebody give a clear and simple explanation for this code? For example, supposing that I forget the formula of Y. How can I remember it , and reproduce it long after I work with it ? 回答1: Here's some

我为什么要学 Common Lisp

坚强是说给别人听的谎言 提交于 2019-12-07 08:41:27
我喜欢文本处理,以前热衷于使用数据库技术。现在用 Vim 和 Perl。 我可以不假思索的用 Vim 写 Perl 代码。像聊天一样。Perl 语言的所有特性我都熟悉,几乎不用查询帮助文档。 其他语言中关于文本处理,正则表达式的函数和算法,我都比较感兴趣。 拥有不同语法的语言,我也当成一种文本。 我越来越发现,每天处理的大都是语言本身造成的问题。 彼此之间有着语法和文化的鸿沟,互相之间充满了误解。 我决定写一个通用的语言解析算法,可以让不同的语言可以相互转换。 这是一个巨大的挑战,但不管多困难,都是值得的。 第一阶段. 我打算将 BNF 语言描述的语法作为配置文件进行解析,并生成相应的规则。 很快发现,太多的精力放在解析这门语言上,BNF 语系有太多的不同,难道我要用那么多精力,累死在做 BNF 的语言转换器的路上吗? 因为转换 BNF 到数据结构,只是时间上的问题,技术不是问题。何必浪费时间在这上面呢?一定有许多人可以把这个做的很好。 既然解析语言是为了转换成内部数据结构,我为什么不用表示数据结构的语言来做我的配置文件呢? 我决定用数据结构的表示形式来做配置文件。 进度加快了,但又遇到了问题,由于调试的问题,我需要在数据结构中加上暂停和注释的功能. 由于动态规则的问题,我需要对这个数据结构进行动态生成,而我的数据结构没有什么规则可言,不久,关键字和操作符也要加到这门语言当中

Saving lisp state

两盒软妹~` 提交于 2019-12-07 08:12:14
问题 I am a beginner in lisp and have a question. When I writing some code directly in REPL (without any .lisp file!), how can I save my work/state of the interpreter to restore it next time and continue working? (I am using ECL) Thanx! And sorry for my broken english ;) 回答1: From the ECL manual: Tratidionally, Common Lisp implemenations have provided a function to save the dump all data from a running Lisp process into a file. The result was called the Lisp image and could be shipped to other

使用 Clozure CL 在 Cocoa 窗口组件中实现显示中文字符串的简单方法

早过忘川 提交于 2019-12-07 07:51:10
使用 Clozure CL 在 Cocoa 窗口组件中实现显示中文字符串的简单方法 目录 0 概述 1 Objective-C 和 Lisp 的不同方法 2 英文标题代码示例 3 中文标题代码示例 0 概述 我们知道, 在 Cocoa 中提供了两种字符串类: NSString 和 NSMutableString, 前者用于处理内容不变, 固定的字符串, 比如窗口标题; 后者用于处理内容可变的字符串, 当然后者也可以用于前者的使用场合. 因为后者 NSMutableString 类是在继承 NSString 类的继承上创建的, 所以 NSMutableString 具有NSString 中所有的功能. 1 Objective-C 和 Lisp 的不同方法 在 Objective-C 代码中通常会使用如下的格式来定义字符串: NSString string = @"This is my string"; 语法非常简单明了, 但是有一个问题:使用加 @ 符号的方式只能定义英文数字字符串, 如果想定义中文等多字节字符串, 这种方法是不支持的. 下面给出一种 Objective-C 中定义中文字符串的示例: NSString* string; string = [NSString stringWithCString:"你好,我是中文字符串!" encoding

Cocoa Bridge -Common Lisp 简单窗口绘图实例 (教程翻译)

南楼画角 提交于 2019-12-07 07:51:01
Cocoa Bridge -Common Lisp 简单窗口绘图实例 (教程翻译) === 原文地址: 网络: http://trac.clozure.com/ccl/wiki/CocoaBridge 原文标题: Cocoa Bridge 翻译者: FreeBlues 2013-07-21 === 目录 0 Cocoa 桥 Cocoa Bridge 1 组件使用 Elementary Usage 1.1 基本窗口 1.2 更多绘图 More drawing 0 Cocoa 桥 Cocoa Bridge 如同在 OpenMCL FFI 章节中讨论的那样( http://trac.clozure.com/ccl/wiki/OpenMclFfi ), OpenMCL 拥有一个非常强大的接口, 对于存在于 Lisp 的映像之外的接口库和组件的世界而言. 其中最重要的是 Cocoa 桥,一个 Mac OS X 用户接口的绑定层。 一本很好的介绍 Cocoa 的读物是 Aaron Hillegass 的 <Cocoa Programming for Mac OS X>( http://www.amazon.com/Cocoa-Programming-Mac-OS-2nd/dp/0321213149 ). 1 组件使用 Elementary Usage 1.1 基本窗口 这里有一个非常简单的例子

用Lisp(CCL)调用Cocoa的nib文件--Nib-Loading 使用指导(教程翻译)

∥☆過路亽.° 提交于 2019-12-07 07:50:46
用Lisp(CCL)调用Cocoa的nib文件-Nib-Loading 使用指导(教程翻译) === 原文地址: http://trac.clozure.com/ccl/browser/trunk/source/examples/cocoa/nib-loading/HOWTO.html 原文标题: Nib-Loading HOWTO 翻译者: FreeBlues 2013-06-17 === 目录 0 概述 1 Nibfiles 的相关知识 2 对 Nibfiles 的使用 3 如何调用一个 nibfile 3.1 获取区域 zone 3.2 建立字典 3.3 调用 nibfile 4 建立一个 nib-loading 函数 5 如何卸载 nibfile 0 概述 这篇教程说明如何通过对 Lisp 形式(forms)求值, 加载 nibfiles 到正在运行的 Clozure CL 副本中。你可能想通过这种方式加载 nibfiles 来为你正在工作的一个应用程序项目来测试用户界面元素,或使应用程序能够动态加载可选的用户界面元素。 1 Nibfiles 的相关知识 Cocoa应用程序开发有很大一部分是使用Cocoa框架来创建用户界面元素的。虽然它是完全有可能只是通过对框架的方法调用创建任何用户界面元素,设计用户界面更标准的方式是使用苹果的 InterfaceBuilder

How do I ask the Lisp compiler to ignore a (label-variety) function?

£可爱£侵袭症+ 提交于 2019-12-07 07:47:44
问题 I've stared at Steele's Common Lisp the Language until I'm blue in the face, and still have this question. If I compile: (defun x () (labels ((y ())) 5)) (princ (x)) (terpri) this happens: home:~/clisp/experiments$ clisp -c -q x.lisp ;; Compiling file /u/home/clisp/experiments/x.lisp ... WARNING in lines 1..3 : function X-Y is not used. Misspelled or missing IGNORE declaration? ;; Wrote file /u/home/clisp/experiments/x.fas 0 errors, 1 warning home:~/clisp/experiments$ Fair enough. So how do I

Position of All Matching Elements in List

自闭症网瘾萝莉.ら 提交于 2019-12-07 07:46:09
问题 I'm trying to write a function in Common Lisp similar to the built in position function, that returns a list of the positions of all elements in the haystack that match the needle, as opposed to just the first. I've come up with a few possible solutions (for example recursively searching for the next element using a cdr-from function on the position and adding the result to the previous position) but none of the approaches I've come up with so far seem particularly elegant. Can anyone suggest