lisp

LispBox 集成开发环境分析 (一)Windows版本分析

巧了我就是萌 提交于 2019-12-01 10:21:11
LispBox 集成开发环境分析 (一)Windows版本分析 LispBox 是一个开源的LISP 集成开发环境,由 SLIME (The Superior Lisp Interaction Mode for Emacs) 交互接口、 Quicklisp 库管理器、 Clozure Common Lisp 编译器和 Emacs 编辑器组成,有WINDOWS、LINUX和MAC OSX三种版本,目前已经停止更新,下载地址为: http://www.common-lisp.net/project/lispbox/ 使用方法很简单,只要把对应的版本下载回去,然后直接执行对应的程序即可启动整个LISP 开发环境了,比如: 1、在WINDOWS下执行 lispbox.bat 2、在LINUX下执行 lispbox.sh 3、在MAC环境下执行 Emacs 对于新手来说不需要进行任何配置工作,非常方便,所以虽然 LispBox 已经停止更新,但是对于Lisp初学者我还是推荐使用LispBox。 本文是一个学习记录,为了避免学了后面的忘记前面的,所以把学习过程中每个阶段理解的内容都用书面的形式做一个总结,以便温故而知新。 首先从LISPBOX的目录结构开始: 解压后的Lispbox 目录名为 "\lispbox-0.7-ccl-1.6-windowsx86\lispbox-0.7\"

CHLS “innermost backquoted form should be expanded first” meaning

半城伤御伤魂 提交于 2019-12-01 09:36:31
CLHS on backquotes states "If the backquote syntax is nested, the innermost backquoted form should be expanded first. This means that if several commas occur in a row, the leftmost one belongs to the innermost backquote." But when I evaluate the following nested backquote expression in SBCL `(outer `(inner ,@(no ,@(list 'cat 'dog)))) ; expression P I get (OUTER `(INNER ,@(NO CAT DOG))) It seems that the outer backquoted form (rather than the inner backquoted form) of expression P is expanded in the sense that: outer backtick is gone, while inner backtick is still there after evaluation only

Lisp: How to get all possible combinations of the elements from lists contained on a list?

折月煮酒 提交于 2019-12-01 09:21:35
问题 I need to write a function in Common-Lisp that takes a list of lists and returns a list containing all the possible combinations of the elements from the sublists. So, for example calling the function on a list such as ((1 2) (1 2)) should return a list like ((1 1) (1 2) (2 1) (2 2)). The input list can be of any length and the sublists are not guaranted to have the same length. I know how to get this with paired elements from the sublists ( inputtting ((1 2) (1 2)) returns ((1 1) (2 2)), but

Reading an array from a text file in Common Lisp

给你一囗甜甜゛ 提交于 2019-12-01 08:32:39
I am trying to read data (which is actually an array) in Lisp from a text file. I tried to use with-open-file and read-line stuff but could not achieve my goal. What I am looking for is equivalent to doing data=load('filename.txt') in MATLAB, so that I get an array called data which has loaded the whole information in filename.txt . The text file will be in a format like 1.0 2.0 3.0 ... 1.5 2.5 3.5 ... 2.0 3.0 4.0 ... ..... The size may also vary. Thanks a lot in advance. The basic way to do that is to use with-open-file for getting the input stream, read-line in a loop to get the lines, split

Merging symbols in common lisp

半世苍凉 提交于 2019-12-01 08:28:55
I want to insert a char into a list. However, I want to merge this char with the last symbol in the list. With appends and cons the result is always two different symbols. Well, I want one merged symbol to be my result. Example: (XXXX 'a '5) ====> (a5) What I would like to have, instead of: (XXXX 'a '5) ====> (a 5) You cannot "merge symbols" in Lisp. First of all, 5 is not a symbol, but a number. If you want a symbol named "5" you have to type it as |5| (for example). If a function takes the symbol A and symbol |5| , and produces the symbol A5 , it has not merged symbols. It has created a new

Compile lisp / scheme in Notepad++

混江龙づ霸主 提交于 2019-12-01 08:11:13
问题 I'm pretty much into lisp at the moment, and unfortunately i'm only available to code on windows. Is is possible to let Notepad++ take care of the interpreting of my scripts, and display the output in the compiler window? If yes, what interpreter would be the best to use? Thanks! 回答1: I second Charlie's recommendation. Get Emacs and SLIME. On Windows, I might get CLISP if SBCL gives any trouble. Also, Lispworks Personal Edition has got a pretty cool IDE, you could try that. 回答2: I'd consider

Merging symbols in common lisp

我只是一个虾纸丫 提交于 2019-12-01 07:49:09
问题 I want to insert a char into a list. However, I want to merge this char with the last symbol in the list. With appends and cons the result is always two different symbols. Well, I want one merged symbol to be my result. Example: (XXXX 'a '5) ====> (a5) What I would like to have, instead of: (XXXX 'a '5) ====> (a 5) 回答1: You cannot "merge symbols" in Lisp. First of all, 5 is not a symbol, but a number. If you want a symbol named "5" you have to type it as |5| (for example). If a function takes

Reading an array from a text file in Common Lisp

♀尐吖头ヾ 提交于 2019-12-01 07:09:34
问题 I am trying to read data (which is actually an array) in Lisp from a text file. I tried to use with-open-file and read-line stuff but could not achieve my goal. What I am looking for is equivalent to doing data=load('filename.txt') in MATLAB, so that I get an array called data which has loaded the whole information in filename.txt . The text file will be in a format like 1.0 2.0 3.0 ... 1.5 2.5 3.5 ... 2.0 3.0 4.0 ... ..... The size may also vary. Thanks a lot in advance. 回答1: The basic way

CHLS “innermost backquoted form should be expanded first” meaning

佐手、 提交于 2019-12-01 07:06:24
问题 CLHS on backquotes states "If the backquote syntax is nested, the innermost backquoted form should be expanded first. This means that if several commas occur in a row, the leftmost one belongs to the innermost backquote." But when I evaluate the following nested backquote expression in SBCL `(outer `(inner ,@(no ,@(list 'cat 'dog)))) ; expression P I get (OUTER `(INNER ,@(NO CAT DOG))) It seems that the outer backquoted form (rather than the inner backquoted form) of expression P is expanded

What does the asterisk do in Python other than multiplication and exponentiation? [duplicate]

北城余情 提交于 2019-12-01 06:25:02
This question already has an answer here: asterisk in function call 3 answers proper name for python * operator? 7 answers In Peter Norvig's Lisp interpreter written in Python ( http://norvig.com/lispy.html ), he defines Lisp's eval as follows: def eval(x, env=global_env): "Evaluate an expression in an environment." if isa(x, Symbol): # variable reference return env.find(x)[x] elif not isa(x, list): # constant literal return x elif x[0] == 'quote': # (quote exp) (_, exp) = x return exp elif x[0] == 'if': # (if test conseq alt) (_, test, conseq, alt) = x return eval((conseq if eval(test, env)