您的位置:首页 > 其它

MIT/GNU Scheme 第一日

2009-02-02 23:28 260 查看
;---------------------------最原始的-------------------------------

(+ 2 3 4)

;Value: 9

;---------------------------定义Emmbed--------------------

(define x 2)

(define mm (* x 3))

mm

;Value:6

;-----------------------几种函数的定义---------------------

(define (sum a b)

(+ a b))

(sum 1 2)

;Value:3

;------------- Cond 使用   --

(define (abs x)

(cond ( (> x 0) x)

( (< x 0) (- x))

(else 0)))

(abs -11)

;Value :11

;--------------- If 使用 --- 逻辑运算使用, and or not -------------

(define (summ a b c)

(cond ((and (> a b) (> c b)) (+ a c))

((and (> a c) (> b c)) (+ a b))

(else (+ b c))))

(summ 1 2 3)

;Value:5
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: