Racket Libraries
5.1 
5.2 双和􏿴
5.3 􏻿
5.4 􏿰
5.5 
5.6 勺
5.7 
5.8 
5.9 􏺃
5.10 Conditionals
5.11 
5.12 
5.13 未分类
On this page:
5.4.1 例程命名规则
5.4.2 􏿰、􏾌、􏾋、􏾊、􏾉
5.4.3 􏿰^、􏾋^、􏾊^、􏾉^,􏾏^、􏾁^、􏾀^、􏽿^,􏾈^、􏽽^、􏽼^、􏽻^,􏾐^、􏾆^、􏾅^、􏾄^,􏿰化􏿳
5.4.4 􏿰?,􏾌?、􏾋?、􏾊?、􏾉?,􏾎?、􏾏?、􏾈?,􏻵?
5.4.5 􏿰􏺈、􏿰􏺇,􏿰日?
5.4.6 􏿰弔、􏿰𫼛,􏿰􏽙,􏿰􏾘、􏿰􏽘
5.4.7 􏿰攸、􏿰攸+  ,􏿰􏾩、􏿰􏾩+  ,􏿰攸/  入、􏿰􏾩/  
5.4.8 􏿰𠛮、􏿰􏽗,𠛮􏿰
5.4.9 􏿰各、􏿰􏺆、􏿰佫
5.4.10 􏿰􏺈仔?
5.4.11 􏿰巨
5.4.12 􏾑化
5.4.13 基础例程
􏿰
􏾋
􏾊
􏾉
􏿰?
􏾌?
􏾋?
􏾊?
􏾉?
􏾎?
􏾏?
􏾈?
􏿰^
􏾋^
􏾊^
􏾉^
􏾐^
􏾆^
􏾅^
􏾄^
􏾏^
􏾁^
􏾀^
􏽿^
􏾈^
􏽽^
􏽼^
􏽻^
􏿰攸
􏿰攸+
􏿰攸/  
􏿰􏾩
􏿰􏾩+
􏿰􏾩/  
􏿰弔
􏿰􏽙
􏿰𫼛
􏿰日?
􏿰􏾘
􏿰􏽘
􏿰𠛮
􏿰􏽗
𠛮􏿰
􏿰􏺆
􏿰佫
􏿰􏺈
􏿰􏺇
􏿰化􏿳
􏿰􏺈仔?
􏿰各
􏿰巨
􏻵?
?􏿰引
?􏿰继引
?􏿰引日
?􏿰引月
?􏿰引明
?􏿰引日月
􏾑化
5.4.14 额外例程
􏿰并
􏿰并!
􏿰交!
8.12

5.4 􏿰🔗

另见名扩展库:􏿰

􏿰”(hash)是一种内部元素都是“键值对(key/value)”的数据结构。

5.4.1 例程命名规则🔗

Naming Rules,有:

规则

指示

含义

举例

/// + 􏿰

“􏿰”中“键值对”唯一性的确立方式

是通过与之对应的同?/􏾗?/􏾃?/侗?中的任一者所确立的

􏾌􏾋􏾊􏾉

/ + 􏿰

“􏿰”中“键值对”是否可变

是不可或可被增加、删除或修改的

􏾐?􏾑?

/ + 􏿰

“􏿰”中“键值对”之“键”的存储方式

是刚性或柔性的

􏾎?􏾏?

相似集(类型相同且元素相似)

出参数据与进参数据相比,类型相同且内容类似

􏿰攸

连续集(类型相同且元素连续相同)

出参数据与进参数据相比,类型相同且前者是后者的一部分

􏿰􏺈􏿰􏺇

缺失集(删除、移走、去掉部分元素之后的集合)

出参数据与进参数据相比,类型相同且前者是后者的子集

􏿰􏾘􏿰𠛮

/!结尾

修改警示

会直接修改原始数据而非另造新数据作输出

􏿰􏾩􏿰𫼛􏿰𫼛􏿰􏽘􏿰􏽗

^结尾

入参

入参数据是􏿳类数据

􏿰^􏾋^􏾊^􏾉^

+结尾

入参

入参数据以相同方式多次出现

􏿰攸+􏿰􏾩+

5.4.2 􏿰、􏾌、􏾋、􏾊、􏾉🔗


􏿰为新造字
  • 广:工厂、容器、外壳;

  • :键值对(因为类似,另见:􏿳);

􏾌􏾋􏾊􏾉为新造字
  • 的简写,见同?

  • 􏾗的简写,见􏾗?

  • 􏾃的简写,见􏾃?

  • 的简写,见侗?

􏾐􏾑􏾎􏾏􏾈为新造字
  • :稳定的、内容不变的(因为“山”是稳定的,见:􏾐?);

  • :易动的、内容可变的(因为“水”是易变的,见:􏾑?);

  • :刚韧的(因为“竹”是刚韧的,见:􏾎?);

  • :柔弱的(因为“艸”(草)是柔弱的,见:􏾏?);

  • (中间加):见􏾈?

􏻵为新造字
  • :简写,通

另见:􏾑

“􏿰”在以下特性上可以被进一步细分:
  • 是否可以增加、修改、删除“键值对”,即“􏿰”的内容是否可以被改变:
    • 􏾐:内容不可改变的“􏿰”,也称“固􏿰”;

    • 􏾑:内容可改变的“􏿰”,也称“易􏿰”(偏旁相关的例程或以!结尾的例程只能作用在“易􏿰”上)。

  • 不能有重复的“键值对”,即“键值对”的唯一性要如何被确立(通过各个“键值对”之间“键”的相互比较来确立):

  • 对于“键值对”,其“键”的存储可以是:
    • 􏾎:刚性的;

    • 􏾏:柔性的;

    • 􏾈:类􏾧的。

通过􏿰创建的是􏾌?􏾎?􏾐?都是真的“􏿰”。

Examples:
> (􏿰 1 2 3 4)

'#hash((1 . 2) (3 . 4))

> (􏽮? (􏿰 1 2 3 4))

#t

5.4.3 􏿰^、􏾋^、􏾊^、􏾉^,􏾏^、􏾁^、􏾀^、􏽿^,􏾈^、􏽽^、􏽼^、􏽻^,􏾐^、􏾆^、􏾅^、􏾄^,􏿰化􏿳🔗


“􏿳”和“􏿰”可以互相进行转换,􏿳化在此用^标记来简写。
通过􏿰^创建的是􏾌?􏾎?􏾑?都为真的“􏿰”。

另见:􏾑􏿳

Examples:
> (􏿰^ '((1 . 2) (3 . 4)))

'#hash((1 . 2) (3 . 4))

> (􏽦? (􏿰^ '((1 . 2) (3 . 4))))

#t

> (􏾏^ '((1 . 2) (3 . 4)))

'#hash((1 . 2) (3 . 4))

> (􏽦? (􏾏^ '((1 . 2) (3 . 4))))

#f

> (􏾁^ '((1 . 2) (3 . 4)))

'#hashalw((1 . 2) (3 . 4))

> (􏽡? (􏾁^ '((1 . 2) (3 . 4))))

#t

> (􏿰化􏿳 (􏿰 1 2 3 4))

'((1 . 2) (3 . 4))

> (􏿰化􏿳 (􏾋 1 2 3 4))

'((1 . 2) (3 . 4))

> (􏿰化􏿳 (􏾑 1 2 3 4))

'((1 . 2) (3 . 4))

5.4.4 􏿰?,􏾌?、􏾋?、􏾊?、􏾉?,􏾎?、􏾏?、􏾈?,􏻵?🔗


另见:
􏾐?􏾑?
􏽞?􏽝?􏽜?􏽛?
􏽮?􏽭?􏽬?􏽫?
􏽦?􏽥?􏽤?􏽣?
􏽪?􏽩?􏽨?􏽧?
􏽢?􏽡?􏽠?􏽟?

Examples:
> (􏿰? (􏿰 1 2 3 4))

#t

> (􏾌? (􏿰 1 2 3 4))

#t

> (􏾎? (􏿰 1 2 3 4))

#t

> (􏾐? (􏿰 1 2 3 4))

#t

> (􏽮? (􏿰 1 2 3 4))

#t

> (􏿰^ '((1 . 2) (3 . 4)))

'#hash((1 . 2) (3 . 4))

> (􏾌? (􏿰^ '((1 . 2) (3 . 4))))

#t

> (􏾎? (􏿰^ '((1 . 2) (3 . 4))))

#t

> (􏾑? (􏿰^ '((1 . 2) (3 . 4))))

#t

> (􏽦? (􏿰^ '((1 . 2) (3 . 4))))

#t

> (􏽦? (􏾏^ '((1 . 2) (3 . 4))))

#f

> (􏽡? (􏾁^ '((1 . 2) (3 . 4))))

#t

> (􏻵? (􏿰 'a "aa" 'b "bb"))

#f

> (􏻵? (􏿰))

#t

5.4.5 􏿰􏺈、􏿰􏺇,􏿰日?🔗


􏺈为古活字
􏺇为新造字
  • :“键值对”的“键”();

  • :“键值对”的“值”()。

对于􏿰中的“键值对”,因其类于,故在此也称为“明”(+)。进而,“键值对”的“键”称为“日”,“值”称为“月”。

Examples:
> (􏿰􏺈 (􏿰 'a "apple" 'b "banana"))

'(b a)

> (􏿰􏺇 (􏿰 'a "apple" 'b "banana"))

'("banana" "apple")

> (􏿰日? (􏿰 'a "apple" 'b "banana") 'a)

#t

5.4.6 􏿰弔、􏿰𫼛,􏿰􏽙,􏿰􏾘、􏿰􏽘🔗


𫼛为古活字
􏽙为新造字
􏾘为新造字
􏽘为新造字

Examples:
> (􏿰弔 (􏿰 'a "apple" 'b "banana") 'b)

"banana"

> (􏿰弔 (􏿰 'a "apple" 'b "banana") 'b "cat")

"banana"

> (􏿰弔 (􏿰 'a "apple" 'b "banana") 'c "cat")

"cat"

> (􏿰􏽙 (􏿰 'a "apple" 'b "banana") 'b)

'b

> (􏿰􏽙 (􏿰 'a "apple" 'b "banana") 'b "cat")

'b

> (􏿰􏽙 (􏿰 'a "apple" 'b "banana") 'c "cat")

"cat"

> (􏿰􏾘 (􏿰 'a "apple" 'b "banana") 'a)

'#hash((b . "banana"))

> ( h (􏾑 'a "apple" 'b "banana"))
> (􏿰𫼛 h 'b "cat")

"banana"

> h

'#hash((a . "apple") (b . "banana"))

> (􏿰𫼛 h 'c "cat")

"cat"

> h

'#hash((a . "apple") (b . "banana") (c . "cat"))

> (􏿰􏽘 h 'a)
> h

'#hash((b . "banana") (c . "cat"))

5.4.7 􏿰攸、􏿰攸+,􏿰􏾩、􏿰􏾩+,􏿰攸/入、􏿰􏾩/入🔗


参见:

Examples:
> (􏿰攸 (􏿰 'a "apple" 'b "banana") 'b "ba")

'#hash((a . "apple") (b . "ba"))

> (􏿰攸+ (􏿰 'a "apple" 'b "banana") 'a "ap" 'b "ba")

'#hash((a . "ap") (b . "ba"))

> (􏿰攸/入 (􏿰 'a "apple" 'b "banana" 'c 1) 'c 􏽊)

'#hash((a . "apple") (b . "banana") (c . 2))

> ( h (􏾑 'a "apple" 'b "banana"))
> (􏿰􏾩+ h 'a "ap" 'b "ba")
> h

'#hash((a . "ap") (b . "ba"))

5.4.8 􏿰𠛮、􏿰􏽗,𠛮􏿰🔗


𠛮为古活字
  • :删除;

Examples:
> (􏿰𠛮 (􏿰 'a "apple" 'b "banana"))

'#hash()

> ( h (􏾑 'a "apple" 'b "banana"))
> (􏿰􏽗 h)
> h

'#hash()

> (𠛮􏿰 (􏿰 'a "apple" 'b "banana"))

'#hash()

5.4.9 􏿰各、􏿰􏺆、􏿰佫🔗


􏺆为新造字
  • 􏿴的缩写;

参见:

Examples:
> (􏿰各 (􏿰 'a "apple" 'b "banana") ( (K V) ( K) ( V)))

'b"banana"'a"apple"

> (􏿰􏺆 (􏿰 'a "apple" 'b "banana") ( (K V) (􏿴 V K)))

'(("banana" b) ("apple" a))

> (􏿰佫 (􏿰 'a "apple" 'b "banana") ( (K V) (􏸼 V K)))

􏸼: undefined;

 cannot reference an identifier before its definition

  in module: top-level

5.4.10 􏿰􏺈仔?🔗


参见:􏿰􏺈仔?

Examples:
> (􏿰􏺈仔? (􏿰 'a "aa" 'b "bb") (􏿰 'a "aaa" 'b "bbb" 'c "ccc"))

#t

> (􏿰􏺈仔? (􏿰 'a "aa" 'c "cc") (􏿰 'a "aaa" 'b "bbb" 'c "ccc"))

#t

> (􏿰􏺈仔? (􏿰 'a "aa" 'd "dd") (􏿰 'a "aaa" 'b "bbb" 'c "ccc"))

#f

> (􏿰􏺈仔? (􏿰 'b "bb") (􏿰 'a "aaa" 'b "bbb" 'c "ccc"))

#t

5.4.11 􏿰巨🔗


参见:空?

Example:
> (􏿰巨 (􏿰 'a "aa" 'b "bb"))

2

5.4.12 􏾑化🔗


Examples:
> (􏾐? (􏿰 'a "aa" 'b "bb"))

#t

> (􏾐? (􏾑化 (􏿰 'a "aa" 'b "bb")))

#f

5.4.13 基础例程🔗

汉字化

􏿰 : 创建􏾌 【MORE】 = hash

汉字化

􏾋 : 类上,不过键的唯一性是通过􏾗?确立的 【MORE】 = hashalw

汉字化

􏾊 : 类上,不过键的唯一性是通过􏾃?确立的 【MORE】 = hasheqv

汉字化

􏾉 : 类上,不过键的唯一性是通过侗?确立的 【MORE】 = hasheq

汉字化

􏿰? : 是否是􏾌􏾋􏾊􏾉的任一种 【MORE】 = hash?

汉字化

􏾌? : 是否是􏾌 【MORE】 = hash-equal?

汉字化

􏾋? : 是否是􏾋 【MORE】 = hash-equal-always?

汉字化

􏾊? : 是否是􏾊 【MORE】 = hash-eqv?

汉字化

􏾉? : 是否是􏾉 【MORE】 = hash-eq?

汉字化

􏾎? : 类上,键是否是被刚性存储的 【MORE】 = hash-strong?

汉字化

􏾏? : 类上,键是否是被柔性存储的 【MORE】 = hash-weak?

汉字化

􏾈? : 类上,键的存储是否是采用􏾧 【MORE】 = hash-ephemeron?

汉字化

􏿰^ : 􏿳转换成􏾑 【MORE】 = make-hash

汉字化

􏾋^ : 􏿳转换成􏾑 【MORE】 = make-hashalw

汉字化

􏾊^ : 􏿳转换成􏾑 【MORE】 = make-hasheqv

汉字化

􏾉^ : 􏿳转换成􏾑 【MORE】 = make-hasheq

汉字化

􏾐^ : 如上类推 【MORE】 = make-immutable-hash

汉字化

􏾆^ : 如上类推 【MORE】 = make-immutable-hashalw

汉字化

􏾅^ : 如上类推 【MORE】 = make-immutable-hasheqv

汉字化

􏾄^ : 如上类推 【MORE】 = make-immutable-hasheq

汉字化

􏾏^ : 如上类推 【MORE】 = make-weak-hash

汉字化

􏾁^ : 如上类推 【MORE】 = make-weak-hashalw

汉字化

􏾀^ : 如上类推 【MORE】 = make-weak-hasheqv

汉字化

􏽿^ : 如上类推 【MORE】 = make-weak-hasheq

汉字化

􏾈^ : 如上类推 【MORE】 = make-ephemeron-hash

汉字化

􏽽^ : 如上类推 【MORE】 = make-ephemeron-hashalw

汉字化

􏽼^ : 如上类推 【MORE】 = make-ephemeron-hasheqv

汉字化

􏽻^ : 如上类推 【MORE】 = make-ephemeron-hasheq

汉字化

􏿰攸 : 以新造数据的方式来修改某“键”对应的“值” 【MORE】 = hash-set

汉字化

􏿰攸+ : 以新造数据的方式来修改某些“键”所对应的“值” 【MORE】 = hash-set*

汉字化

􏿰攸/入 : 类上,区别是入参不同 【MORE】 = hash-update

汉字化

􏿰􏾩 : 直接修改某“键”对应的“值” 【MORE】 = hash-set!

汉字化

􏿰􏾩+ : 直接修改某些“键”所对应的“值” 【MORE】 = hash-set*!

汉字化

􏿰􏾩/入 : 类上,区别是入参不同 【MORE】 = hash-update!

汉字化

􏿰弔 : 以“键值对”中“阳”位数据为基准,来索引查询“键值对”并返回“阴”位数据(未找到数据则返回默认设置值); 【MORE】

 = hash-ref

汉字化

􏿰􏽙 : 以“键值对”中“阳”位数据为基准,来索引查询“键值对”并返回“阳”位数据; 【MORE】 = hash-ref-key

汉字化

􏿰𫼛

 : 以“键值对”中“阳”位数据为基准,来索引查询“键值对”并返回“阴”位数据(未找到数据则直接修改原数据增加新“键值对”); 【MORE】
 = hash-ref!

汉字化

􏿰日? : 是否存在某“键” 【MORE】 = hash-has-key?

汉字化

􏿰􏾘 : 以新造数据的方式来删除某“键”和其对应的“值” 【MORE】 = hash-remove

汉字化

􏿰􏽘 : 直接删除某“键”和其对应的“值” 【MORE】 = hash-remove!

汉字化

􏿰𠛮 : 以新造数据的方式来删除全部“键”和其对应的“值” 【MORE】 = hash-clear

汉字化

􏿰􏽗 : 直接删除全部“键”和其对应的“值” 【MORE】 = hash-clear!

汉字化

𠛮􏿰 : 以删除全部“键”和其对应的“值”的方式新造空数据 【MORE】 = hash-copy-clear

汉字化

􏿰􏺆 : 把某一个例程依次作用在各个明(键值对)上,出参是􏿴 【MORE】 = hash-map

汉字化

􏿰佫 : 把某一个例程依次作用在各个明(键值对)上 【MORE】 = hash-map/copy

汉字化

􏿰􏺈 : 返回􏿰中所有键值对的“键”组成的􏿴 【MORE】 = hash-keys

汉字化

􏿰􏺇 : 返回􏿰中所有键值对的“值”组成的􏿴 【MORE】 = hash-values

汉字化

􏿰化􏿳 : 【MORE】 = hash->list

汉字化

􏿰􏺈仔? : 前者是否是后者的的子集 【MORE】 = hash-keys-subset?

汉字化

􏿰各 : 【MORE】 = hash-for-each

汉字化

􏿰巨 : 【MORE】 = hash-count

汉字化

􏻵? : 【MORE】 = hash-empty?

汉字化

?􏿰引 : 【MORE】 = hash-iterate-first

汉字化

?􏿰继引 : 【MORE】 = hash-iterate-next

汉字化

?􏿰引日 : 【MORE】 = hash-iterate-key

汉字化

?􏿰引月 : 【MORE】 = hash-iterate-value

汉字化

?􏿰引明 : 【MORE】 = hash-iterate-pair

汉字化

?􏿰引日月 : 【MORE】 = hash-iterate-key+value

汉字化

􏾑化 : 􏾐转化为􏾑 【MORE】 = hash-copy

5.4.14 额外例程🔗

汉字化

􏿰并 : 【MORE】 = hash-union

汉字化

􏿰并! : 【MORE】 = hash-union!

汉字化

􏿰交! : 【MORE】 = hash-intersect