sbcl

DELETE is destructive — but not always?

梦想与她 提交于 2019-12-01 06:49:13
问题 I'm a little confused about Common Lisp's destructive DELETE function. It seems to work as expected, except for if the item is the first item on the list: CL-USER> (defvar *test* (list 1 2 3)) *TEST* CL-USER> (delete 1 *test*) (2 3) CL-USER> *test* (1 2 3) CL-USER> (delete 2 *test*) (1 3) CL-USER> *test* (1 3) 回答1: "Destructive" does not mean "operates in place". It means that the structure of the value operated on might be modified in some arbitrary and often undefined way. This can in some

Using deftransform/defknown in SBCL internals to get the compiler to transform user authored functions

回眸只為那壹抹淺笑 提交于 2019-12-01 05:55:40
At the end of section 6.5 in the current SBCL manual, we have the following quote: If your system's performance is suffering because of some construct which could in principle be compiled efficiently, but which the SBCL compiler can't in practice compile efficiently, consider writing a patch to the compiler and submitting it for inclusion in the main sources. Such code is often reasonably straightforward to write; search the sources for the string “deftransform” to find many examples (some straightforward, some less so). I've been playing around and found the likes of sb-c::defknown and sb-c:

Defining aliases to standard Common Lisp functions?

自闭症网瘾萝莉.ら 提交于 2019-12-01 04:00:49
问题 Lisp is said to enable redefinitions of its core functions. I want to define an alias to the function cl:documentation function, such that (doc 'write 'function) === (documentation 'write 'function) How can this be done and made permanent in SBCL? 回答1: Creating an Alias You are not trying to redefine (i.e., change the definition of) the system function documentation, you want to define your own function with a shorter name which would do the same thing as the system function. This can be done

Using deftransform/defknown in SBCL internals to get the compiler to transform user authored functions

折月煮酒 提交于 2019-12-01 03:42:46
问题 At the end of section 6.5 in the current SBCL manual, we have the following quote: If your system's performance is suffering because of some construct which could in principle be compiled efficiently, but which the SBCL compiler can't in practice compile efficiently, consider writing a patch to the compiler and submitting it for inclusion in the main sources. Such code is often reasonably straightforward to write; search the sources for the string “deftransform” to find many examples (some

Does Common Lisp have a something like java's Set Interface/implementing classes?

风流意气都作罢 提交于 2019-12-01 03:35:38
I need something like this , a collection of elements which contains no duplicates of any element. Does Common Lisp, specifically SBCL, have any thing like this? For a quick solution, just use hash tables, as has been mentioned before. However, if you prefer a more principled approach, you can take a look at FSet , which is “a functional set-theoretic collections library”. Among others, it contains classes and operations for sets and bags. (EDIT:) The cleanest way would probably be to define your set-oriented operations as generic functions. A set of generic functions is basically equivalent

Does Common Lisp have a something like java's Set Interface/implementing classes?

孤街浪徒 提交于 2019-11-30 23:55:56
问题 I need something like this, a collection of elements which contains no duplicates of any element. Does Common Lisp, specifically SBCL, have any thing like this? 回答1: For a quick solution, just use hash tables, as has been mentioned before. However, if you prefer a more principled approach, you can take a look at FSet, which is “a functional set-theoretic collections library”. Among others, it contains classes and operations for sets and bags. (EDIT:) The cleanest way would probably be to

Writing Common Lisp code that executes from the command line, but not inside the interpreter

孤街浪徒 提交于 2019-11-30 07:04:45
When writing Common Lisp code, I use SLIME. In particular, I compile the buffer containing definitions of functions by using C-C C-k, and then switch to the REPL to run those functions. Putting executable code to run those functions in the buffer does not appear to work so well. If the code has bugs it can make a mess. It would be handy to have a way to include code that doesn't get compiled in the buffer, but do get run from the command line, e.g. when doing sbcl --script foo.lisp If that were the case, I would not have to keep adding and removing code every time I wanted to run code from the

【实践】MS WINDOWS系统中把 SBCL 集成到 Lispbox 中

≡放荡痞女 提交于 2019-11-30 05:15:06
【实践】MS WINDOWS系统中把 SBCL 集成到 Lispbox 中 最近在分析 Lispbox 中各个组成部分的启动顺序和调用方法,略有所得,遂尝试把 SBCL 集成到 Lispbox,具体方法如下: 1、安装好 Lispbox , 直接下载解压就可以了(我的安装目录是 F:\lispbox-0.9); 1、安装好WINDOWS版本的SBCL(我的安装目录是 D:\Program Files\Steel Bank Common Lisp\1.1.0); 3、在 lispbox-0.9 目录下新建一个目录 Steel-Bank-Common-Lisp,把 D:\Program Files\Steel Bank Common Lisp\1.1.0\ 下的所有文件和文件夹全部拷贝到 F:\lispbox-0.9\Steel-Bank-Common-Lisp\ 目录下; 4、修改 F:\lispbox-0.9\emacs-24.2\site-lisp\ 下的 lispbox.el 文件,修改为如下: ;(setenv "SBCL_HOME" (lispbox-file "sbcl-1.0.42/lib/sbcl")) (setenv "SBCL_HOME" (lispbox-file "Steel-Bank-Common-Lisp")) 5、把 F:\lispbox-0.9\ccl

How to process input and output streams in Steel Bank Common Lisp?

青春壹個敷衍的年華 提交于 2019-11-30 04:11:55
I'm trying to figure out how to use the output stream of one program I start with RUN-PROGRAM so it can be used as the input of another program started with RUN-PROGRAM (i.e., the moral and perhaps literal equivalent of piping). I've tried using a number of combinations of the :INPUT , :OUTPUT and :WAIT keyword arguments, but nothing I've hit upon has been productive so far. Any tips would be helpful; for example, how would I go about doing something like ls | grep lisp from the shell? One of my attempts is (defun piping-test () (let ((grep-process (run-program "/usr/bin/grep" '("lisp") :input

How to use buildapp in combination with quicklisp

馋奶兔 提交于 2019-11-30 04:00:57
I want to use buildapp to make the curl-lisp executable given as an example : buildapp --output lisp-curl --asdf-path ~/src/clbuild/systems/ \ --load-system drakma \ --eval '(defun main (args) (write-string (drakma:http-request (second args))))' \ --entry main This will most definitly not work, as I got no path "~/src/clbuild/systems/", as I use quicklisp my systems should be at "~/quicklisp/dists/quicklisp/software", but when I execute: buildapp --output lisp-curl \ --asdf-path ~/quicklisp/dists/quicklisp/software \ --load-system drakma \ --eval '(defun main (args) (write-string (drakma:http