Mac OS X 上的安装 Lisp 开发环境

安装环境

 

$ brew install sbcl

安装完毕后使用 sbcl 启动交互环境。 sbcl 这是一个REPL(read–eval–print loop )。

 

开始Common Lisp编程:

 

$ sbcl
This is SBCL 1.5.6, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* 1
1
* 1+2

debugger invoked on a UNBOUND-VARIABLE in thread
#<THREAD "main thread" RUNNING {10004F04C3}>:
  The variable |1+2| is unbound.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [CONTINUE   ] Retry using |1+2|.
  1: [USE-VALUE  ] Use specified value.
  2: [STORE-VALUE] Set specified value and use it.
  3: [ABORT      ] Exit debugger, returning to top level.

简单数字计算

0] (+ 1 2)             

3

0] (* 99 99)

9801

定义函数

(defun avg (x1 x2 x3)
      (/ (+ x1 x2 x3) 3))


(avg 100 80 70)
250/3

在 Lisp 的另外一个方言 Clojure 上:

user=> (defn avg [x1 x2 x3]
          (/ (+ x1 x2 x3) 3))

user=> (avg 12 13 14)
13

 

Kotlin 开发者社区

在这里插入图片描述

国内第一Kotlin 开发者社区公众号,主要分享交流:编程语言、Spring Boot、Android、React.js/Node.js、函数式编程、编程思想、系统架构设计、领域建模等相关主题。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

光剑书架上的书

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值