红色壁虎(三磊)

Red Gecko 石子虽平凡,聚少亦成多。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
Welcome to DrRacket, version 5.1.1 [3m].
Language: R5RS; memory limit: 128 MB.
> 9defune (abs x)
. . reference to undefined identifier: 9defune
. . reference to undefined identifier: x
> (defune (abs x)
    (cond ((> x 0) x)
          ((= x 0) 0)
          ((< x 0) (- x)))) 
. . reference to undefined identifier: defune
> (define (abs x)
    (cond ((> x 0) x)
          ((= x 0) 0)
          ((< x 0) (- x)))) 
define-values: cannot change constant variable: abs
> (define (_abs x)
    (cond ((> x 0) x)
          ((= x 0) 0)
          ((< x 0) (- x)))) 
> (-abs 1)
. . reference to undefined identifier: -abs
> (_abs 1)
1
> (_abs -11)
11
> (_abs 0)
0
> (define (__abs x)
    (cond ((< x 0) -x)
          (else x)))
> (__abs -4)
. . reference to undefined identifier: -x
> (define (__abs x)
    (cond ((< x 0) (- x))
          (else x)))
> (__abs -4)
4
> (__abs 24)
24
> (__abs 0)
0
> (__abs -0)
0
> (define (___abs x)
    (if (< x 0)
        (- x)
        x))
> (___abs -5)
5
> (___abs 95)
95
> (___abs 0)
0
> (___abs -0)
0
> (else)
. else: not allowed as an expression in: (else)
> (else 4)
. else: not allowed as an expression in: (else 4)
> (and  1 3 4)
4
> (and  1 0 4)
4
> (and  1 #f 4)
#f
> (and  #t #f 4)
#f
> (and  1 #t 4)
4
> (or  1 #t 4)
1
> (or  #f #t 4)
#t
> (or  #f #f 4)
4
> (or  #f #f #f)
#f
> (not  #f)
#t
> (not  23)
#f
> (not  2)
#f
> (and (> x 5) (< x 0)
       )
. . reference to undefined identifier: x
> (define (A x) (and (> x 5) (< x 0)))
> (A 3)
#f
> (A 7)
#f
> (define (A x) (and (> x 5) (< x 10)))
> (A 7)
#t
> 10
10
> (+ 5 3 4)
12
> (- 9 1)
8
> (/ 6 2)
3
> (+ (* 2 4) ( - 4 6))
6
> (define a 3)
> (define b (+ a 1))
> (+ a b (* a b))
19
> (= a b)
#f
> (if (and (> b a) ( < b (* a b)))
      b
      a)
4
> (cond ((= a 4) 6)
        ((= b 4) (+ 6 7 a))
        (else 25))
16
> (+ 2 ( if (> b a ) b a ))
     
6
> (* (cond (( < a b ) a )
           (( < a b ) b)
           (else 1))
     (+ a 1))
12
> (* (cond (( > a b ) a )
           (( < a b ) b)
           (else 1))
     (+ a 1))
16
> (/ (+ 5 4 (- 2 (- 3 ( + 6 (/ 4 5))))) ( * 3 (- 6 2) (- 2 7)))
-37/150
> ;练习1.3
(define (lx_1.3 a b c) (- (+ a b c) (cond ((< a b) (if (< a c) a c))
                                          ((< b c) b)
                                          (else c))))
> (lx_1.3 1 2 3)
5
> (lx_1.3 11 2 3)
14
> ;练习1.4
(define ( a-plus-abs-b a b)
  ((if(> b 0) + -) a b))
> (a-plus-abs-b 1 2)
3
> (a-plus-abs-b -1 2)
1
> (a-plus-abs-b -1 -2)
1
> (a-plus-abs-b 1 -2)
3
> 1
1
> (1)
. . procedure application: expected procedure, given: 1 (no arguments)
> (define (p) (p))
> (define (test x y)
    (if ( = x y) x y))]
. read: illegal use of close square bracket
> (define (test x y)
    (if ( = x y) x y))
> (test 0 (p))
. . user break