你好,游客 登录 注册 搜索
背景:
阅读新闻

Ubuntu 中的编程语言

Lisp

[日期:2010-08-11] 来源:Ubuntu社区  作者:skyivben [字体:大 中 小]

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 以前的日期。

linux
【内容导航】
第1页:Java 第2页:Scala
第3页:Visual Basic.NET 第4页:C#
第5页:F# 第6页:C
第7页:C++ 第8页:Python
第9页:Ruby 第10页:JavaScript
第11页:Perl 第12页:PHP
第13页:Pascal 第14页:Delphi
第15页:Fortran 第16页:Lua
第17页:Lisp 第18页:Logo
相关资讯       Linux编程  Ubuntu编程 
本文评论   查看全部评论 (1)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款
第 1 楼
* long 发表于 2010/8/14 23:47:54
赞