On this page:
3.4.1 Ord定义
gen:  Ord
Ordering
ord:  compare
Ord?
3.4.2 Ord操作
compare
>
>=
<
<=
min
max
8.12

3.4 Ord(大小比较)🔗

3.4.1 Ord定义🔗

接口

gen:Ord

大小接口。

最小实现ord:compare

value

Ordering : (or/c 'eq 'lt 'gt)

比较结果。

procedure

(ord:compare a b)  Ordering

  a : Ord?
  b : Ord?

procedure

(Ord? a)  boolean?

  a : any/c
是否gen:Ord实例。

3.4.2 Ord操作🔗

procedure

(compare a b)  Ordering

  a : Ord?
  b : Ord?

Examples:
> (compare 1 1)

'eq

> (compare "hello" "Hello")

'gt

> (compare (list 1 2) (list 1 2 3))

'lt

procedure

(> a b)  boolean?

  a : Ord?
  b : Ord?
(>= a b)  boolean?
  a : Ord?
  b : Ord?
(< a b)  boolean?
  a : Ord?
  b : Ord?
(<= a b)  boolean?
  a : Ord?
  b : Ord?

Examples:
> (> 1 2)

#f

> (>= 2 1)

#t

> (< (list 1 2) (list 2 1))

#t

> (<= (hash) (hash))

#t

procedure

(min a b)  (or/c a b)

  a : Ord?
  b : Ord?
(max a b)  (or/c a b)
  a : Ord?
  b : Ord?

Examples:
> (max 1 1)

1

> (min #\A #\B)

#\A