-
Couldn't load subscription status.
- Fork 26
scheme
thawk edited this page Feb 19, 2020
·
2 revisions
-
库文件搜索路径
(library-directories) ; (("." . ".")) -
库文件扩展名
(library-extensions) ; ((".chezscheme.sls" . ".chezscheme.so") ; (".ss" . ".so") ; (".sls" . ".so") ; (".scm" . ".so") ; (".sch" . ".so"))
-
配置额外的库路径和库文件扩展名
export CHEZSCHEMELIBDIRS="/Users/username/scheme/lib:" export CHEZSCHEMELIBEXTS=".sc::.so:"
结尾的
:表示附加到原有配置下,没有:的话会替换原来的配置。
-
boolean?:#t#f -
number?-
complex?:2+3i -
real?-
rational?:3.147/12 -
integer?-
#b1100: 2进制 -
#o: 8进制 -
#x: 16进制
-
-
-
-
char?:#\c#\x63 -
symbol?:(quote xyz)`xyz-
用字符串来命名。如
`a-symbol、`i18n、`<=>、`$!#* -
用
define来将symbol类型数据当成全局变量(define xyz 9)
-
不能和其他类型冲突,如
`3、`(1 2)不是symbol -
不分大小写
(eqv? `Calorie `calorie) => #t
-
-
string?: 字符序列"hello"(string #\h #\e #\l #\l #\o)-
(make-string 3)->"\x00\x00\x00"
-
vector?: 元素可以为任意类型的序列#(0 #\a "str")(vector 0 #\a "str")(make-vector 3)
-
点对和
list?-
(cons 1 #t)->(1 . #t) '(1 . #t)`(1 . #t)
-
-
and: 返回最后一个值或#f -
or: 第一个非#f值或#f
-
quotient:商 -
remainder:余,可为负数,与quotient配对 -
module:余,正数 -
sqrt:平方根 -
expt:指数 -
log:对数(log a b)为b为底,a的对数。b缺省为e -
=
-
char=?char<?char<=?char>?char >=? char-ci=?-
char-upcasechar-downcase
(string-ref "abc" 0) => #\astring-append-
(string-set! greeting 1 #\E)- 通过
string、make-string和string-append获得的字符串结果都是可以修改的
- 通过
vector-refvector-set!
-
car、cdr -
caar、cdar等-
(cdar x)->(cdr (car x))
-
-
set-car!、set-cdr! -
null?: 空列表 -
pair?: 两个元素的点对 -
list?: 点对最后一个为`() -
list-ref: 指定索引号的元素 -
list-tail: 指定索引号及之后的所有元素
-
exact->inexact:精确数字转换为浮点数(exact->inexact (/ 29 3 7)) ; 1.380952380952381
-
char->integer -
integer->char -
string->list -
number->string -
string->number: 不能转换则为#f。可选第二参数为进制
(define val 1)(set! xyz #\c)(begin (action1) (action2))-
(apply + 1 2 3 (4 5 6)): 最后一个参数必须是列表
-
(if 条件 分支1 分支2) -
when、unless: body隐含了begin -
cond(cond ((char<? c #\c) -1) ((char=? c #\c) 0) (else 1))
-
case(define c #\c) (case c ((#\a) 1) ((#\b) 2) ((#\c) 3) (else 4))
-
let(let ((x 1) (y 2)) (list x y))
-
(define add2 (lambda (x) (+ x 2))) -
可变参数,点对最后一个元素为列表,捕捉剩余的参数
(define fun (lambda (x y . args) ()))
current-output-port
-
当前路径
(current-directory)