首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >撰写和撰写/深度分析规则的红色?

撰写和撰写/深度分析规则的红色?
EN

Stack Overflow用户
提问于 2018-05-23 08:26:32
回答 3查看 89关注 0票数 2

如何保持(打印文本)在使用撰写时消失?

代码语言:javascript
复制
s: {hello test1 parse test2}
t1: "test1"
t2: "test2"

rule: compose [ thru (t1) mark: copy text to (t2) (print text)]
parse s rule

相同的问题用于写作/深度,如果答案不同:

代码语言:javascript
复制
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
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2018-05-23 12:06:39

您可以将块转换为paren,也可以引用paren:

代码语言:javascript
复制
>> compose [something here (to paren! [print text])]
== [something here (print text)]
>> compose [something here (quote (print text))]
== [something here (print text)]

compose/deep的情况也是一样。

票数 4
EN

Stack Overflow用户

发布于 2018-05-23 13:09:24

您不局限于框中的内容,因此您可以创建自己的类似于构图的构造,以完成其他模式。

例如,这里有一个composeII,它只代替有嵌套括号的情况。因此,它将不使用(x),而是计算((x))

代码语言:javascript
复制
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
                ]
            ]
        ]
    ]
]

所以对于你的案子:

代码语言:javascript
复制
>> 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)]
]
票数 6
EN

Stack Overflow用户

发布于 2018-05-24 05:58:06

当块屏蔽它们的内容不受编写的评估时,您也可以使用

代码语言:javascript
复制
>> rule: compose [ thru (t1) mark: copy text to (t2) (first [(print text)] )]
== [thru "test1" mark: copy text to "test2" (print text)]
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50483395

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档