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
>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架