SLIB 是一个可移植的通用 Scheme 库。里面有很多有用的函数,比 如
MzScheme 下的 SLIB 安装:
a. 设置 SCHEME_LIBRARY_PATH 环境变量为 /usr/local/slib。
b. 符号连接 slib 到 plt 的 collects 目录。
首先加载 SLIB 的初始化函数:
(load (build-path (collection-path "slibinit") "init.ss")) 或 (require (lib "load.ss" "slibinit"))
以后,在需要某个功能时,使用
(require '<something>)
加载那个功能。比如:
(require 'charplot)
(set! charplot:dimensions '(25 50))
(define (make-points n)
(if (zero? n)
'()
(cons (cons (/ n 6) (sin (/ n 6))) (make-points (1- n)))))
(plot (make-points 37) "x" "Sin(x)")
得到输出:
Sin(x) ____________________________________
| |
1|- *** |
| * * |
0.8|- * * |
| * * |
0.6|- * * |
| * * |
0.4|- |
| * * |
0.2|-* |
| * |
0|----------------*-------------------|
| * |
-0.2|- * |
| * |
-0.4|- * * |
| * |
-0.6|- * * |
| * |
-0.8|- * * |
| ** * |
-1|- **** |
|:____.____:____.____:____.____:____.|
x 2 4 6
SLIB 的 require 函数和 MzLib 的 require 重名,所以加载 SLIB 初始化文件以后,MzLib 的 require 被改名为 mz:require。 require 实际上是 slib:require。
以后使用
(mz:require <any> ...)
就可以加载 MzLib 的东西了。