如何保持(打印文本)在使用撰写时消失?
s: {hello test1 parse test2}
t1: "test1"
t2: "test2"
rule: compose [ thru (t1) mark: copy text to (t2) (print text)]
parse s rule相同的问题用于写作/深度,如果答案不同:
s: {hello test1 parse test2. hello second test for test1 parse test2.}
t1: "test1"
t2: "test2"
rule: compose/deep [ any [thru (t1) mark: copy text to (t2) (print text)]]
parse s rule发布于 2018-05-23 12:06:39
您可以将块转换为paren,也可以引用paren:
>> compose [something here (to paren! [print text])]
== [something here (print text)]
>> compose [something here (quote (print text))]
== [something here (print text)]compose/deep的情况也是一样。
发布于 2018-05-23 13:09:24
您不局限于框中的内容,因此您可以创建自己的类似于构图的构造,以完成其他模式。
例如,这里有一个composeII,它只代替有嵌套括号的情况。因此,它将不使用(x),而是计算((x))。
composeII: function [block /only /deep] [
collect [
foreach item block [
case [
all [
paren? :item
1 = length? item
paren? first item
][
either only [
keep/only do first item
][
keep do first item
]
]
all [
deep
block? :item
][
either only [
keep/only composeII/deep/only item
][
keep/only composeII/deep item
]
]
true [
keep/only :item
]
]
]
]
]所以对于你的案子:
>> t1: "test1"
>> t2: "test2"
>> composeII/deep [
any [thru ((t1)) mark: copy text to ((t2)) (print text)]
]
== [
any [thru "test1" mark: copy text to "test2" (print text)]
]发布于 2018-05-24 05:58:06
当块屏蔽它们的内容不受编写的评估时,您也可以使用
>> rule: compose [ thru (t1) mark: copy text to (t2) (first [(print text)] )]
== [thru "test1" mark: copy text to "test2" (print text)]https://stackoverflow.com/questions/50483395
复制相似问题