Lisp
Lisp 语言在2010年6月编程语言排行榜中排名第十六位。下面就是 GregorianTest.lisp 程序:
安装 GNU Common Lisp 软件包,gcl 可以作为交互窗口,也可编译源程序(使用 –compile 参数),还可以解释执行(使用 –f 参数):
ben@ben-1520:~/work$ sudo apt-get install gcl
ben@ben-1520:~/work$ gcl
GCL (GNU Common Lisp) 2.6.7 CLtL1 Feb 15 2010 17:57:54
Source License: LGPL(gcl,gmp), GPL(unexec,bfd,xgcl)
Binary License: GPL due to GPL'ed components: (XGCL READLINE BFD UNEXEC)
Modifications of this banner must retain notice of a compatible license
Dedicated to the memory of W. Schelter
Use (help) to get some basic information on how to use GCL.
Temporary directory for compiler files set to /tmp/
>(bye)
ben@ben-1520:~/work$ gcl -f GregorianTest.lisp
Mon 1583-01--88 seconds since 1900-01-01: -10011254400
Tue 1583-01--87 seconds since 1900-01-01: -10011168000
ben@ben-1520:~/work$
运行结果基本和 C 语言一样,但是有一个 bug,认为 1582-10-04 是1583年1月的第 –88 天。这是一个很奇怪的 bug,其它大部分日期是正常的,如下所示:
ben@ben-1520:~/work$ gcl -f GregorianTest2.lisp
Sun 2010-06-20 seconds since 1900-01-01: 3485980800
Mon 2010-06-21 seconds since 1900-01-01: 3486067200
ben@ben-1520:~/work$ gcl -f GregorianTest3.lisp
Tue 1582-05-04 seconds since 1900-01-01: -10024473600
Wed 1582-05-05 seconds since 1900-01-01: -10024387200
ben@ben-1520:~/work$
此外,还可以选择安装 GNU CLISP 软件包,clisp 是符合 ANSI Common Lisp 标准的编译器、解释器和调试器:
ben@ben-1520:~/work$ sudo apt-get install clisp
ben@ben-1520:~/work$ clisp
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.44.1 (2008-02-23)
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-2008
Type :h and hit Enter for context help.
[1]> (bye)
Bye.
ben@ben-1520:~/work$ clisp GregorianTest2.lisp
Sun 2010-06-20 seconds since 1900-01-01: 3485952000
Mon 2010-06-21 seconds since 1900-01-01: 3486038400
ben@ben-1520:~/work$ clisp GregorianTest.lisp
*** - incorrect date: 1582-10-4 0:0:0, time zone NIL
ben@ben-1520:~/work$
可以看出,GNU CLISP 不支持 1900-01-01 以前的日期。