racket 类型变量比较操作示例代码

代码语言:racket

所属分类:其他

代码描述:racket 类型变量比较操作示例代码

代码标签: 比较 操作 示例

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

#lang racket
;; for numbers use `='
(= 3 3.0) ; => #t
(= 2 1)   ; => #f

;; `
eq?' returns #t if 2 arguments refer to the same object (in memory),
;; #f otherwise.
;; In other words, it'
s a simple pointer comparison.
(eq? '() '()) ; => #t, since there exists only one empty list in memory
(let ([x '()] [y '()])
 
(eq? x y))  ; => #t, same as above

(eq? (list 3) (list 3)) ; => #f
(let ([x (list 3)] [y (list 3)])
 
(eq? x y))            ; => #f — not the same list in memory!

(let* ([x (list 3)] [y x])
 
(eq? x y)) ; => #t, since x and y.........完整代码请登录后点击上方下载按钮下载查看

网友评论0