9.2 连接字符串与其它类型的数值
将字符串与其他类型的数值连接在一起。
下面是两个文本,在文本 2 中查找文本 1 的字符串,希望按下面形式返回:
file1 |
---|
like parks |
went out |
go out |
file2 |
---|
I like to go out because I like parks. |
Ben does not go out much. |
Shelly went out often but does not like parks. |
Harry does not go out neither does he like parks. |
希望输出结果如下:
Member |
---|
Q1. like parks |
I |
Shelly |
Harry |
Q2. went out |
Shelly |
Q3. go out |
I |
Ben |
Harry |
使用操作符 / 连接字符串和其他类型值。
脚本:
A | |
---|---|
1 | =file(“file1.txt”).read@n() |
2 | =file(“file2.txt”).read@n() |
3 | =A1.conj((“Q”/#/"."/~)|A2.select(pos(~, A1.~)).(~.words()(1))) |
A1 读取文本 1
A2 读取文本 2
A3 循环文本 1 中的字符串,在文本 2 中查找,并取第一个英文单词。每组搜索结果前拼上 Q 与 A1 的序号和当前成员,其中序号是整数类型,使用操作符 / 连接。
运行结果:
Member |
---|
Q1. like parks |
I |
Shelly |
Harry |
Q2. went out |
Shelly |
Q3. go out |
I |
Ben |
Harry |