clisp编译

目前,lisp的开发环境基本上被lispbox所垄断。所以本文来说一CLISP,C语言实现的LISP解释器的安装。

1
2
3
4
5
wget "https://ftp.gnu.org/pub/gnu/clisp/latest/clisp-2.49.tar.gz"
tar -xvf clisp-2.49.tar.gz
cd clisp-2.49
./configure --prefix=LOCAL_PATH --ignore-absence-of-libsigsegv
cd src && make && make install

这样就可以将CLISP安装到–prefix指定的路径。
然后是使用。

1
2
cd LOCAL_PATH/bin/
./clisp

就会出现欢迎界面:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
  i i i i i i i       ooooo    o        ooooooo   ooooo   ooooo
  I I I I I I I      8     8   8           8     8     o  8    8
  I  \ `+' /  I      8         8           8     8        8    8
   \  `-+-'  /       8         8           8      ooooo   8oooo
    `-__|__-'        8         8           8           8  8
        |            8     o   8           8     o     8  8
  ------+------       ooooo    8oooooo  ooo8ooo   ooooo   8

Welcome to GNU CLISP 2.49 (2010-07-07) <http://clisp.cons.org/>

Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2000
Copyright (c) Sam Steingold, Bruno Haible 2001-2010

Type :h and hit Enter for context help.
[1]>

尝试进行函数求值:

1
2
3
4
5
6
7
[1]> (defun sum(x y) (format t "~d" (+ x y)))
SUM
[2]> (sum 1 2)
3
NIL
[3]> (exit)
Bye.

或者,将以下内容写入test.lisp文件然后执行:

1
2
3
(defun sum(x y)
  (format t "~d" (+ x y)))
(sum 1 2)

执行LOCAL_PATH/bin/clisp test.lisp成功输出。

Licensed under CC BY-NC-SA 4.0
Hello, World!
使用 Hugo 构建
主题 StackJimmy 设计