rebol 中的递归问题

发布于 2024-08-26 04:18:27 字数 843 浏览 5 评论 0原文

我有一个块,我想

folders: [
    Chrome [
        content [
            preferences
            prefpages
        ]
    ]
    icons [
        default
    ]
    locale [
        en-EN [
            csbar
        ]
    ]
    skin
]

用这个函数递归迭代:

iterate-folder: func [folders [block!]][
    foreach folder folders [
        either not block? folder [
            probe folder
            temp: folder
            input
        ] [
            print "folder"
            probe folder
            print "folders"
            probe folders
            probe select folders folder
            type-folder: type? select folders folder
            probe type-folder
            input
            iterate-folder select folders folder
        ]
    ]
]

但由于愚蠢的原因我看不到,探针文件夹上面没有返回任何内容,所以它不起作用。

I have a block on which I want to iterate recursively

folders: [
    Chrome [
        content [
            preferences
            prefpages
        ]
    ]
    icons [
        default
    ]
    locale [
        en-EN [
            csbar
        ]
    ]
    skin
]

with this function:

iterate-folder: func [folders [block!]][
    foreach folder folders [
        either not block? folder [
            probe folder
            temp: folder
            input
        ] [
            print "folder"
            probe folder
            print "folders"
            probe folders
            probe select folders folder
            type-folder: type? select folders folder
            probe type-folder
            input
            iterate-folder select folders folder
        ]
    ]
]

but for stupid reason I can't see, probe folder returns none above so it doesn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贱人配狗天长地久 2024-09-02 04:18:27

我认为是选择文件夹文件夹搞乱了它......文件夹已经是你想要的数据结构了。

试试这个(还要注意询问而不是输入只是为了在此时添加调试字符串):

iterate-folder: func [folders [block!]][
    foreach folder folders [
        either not block? folder [
            probe folder
            temp: folder
            ask "continue/not block"
    ] [
            print "folder"
            probe folder
            print "folders"
            probe folders
            probe select folders folder
            type-folder: folder
            probe type-folder
            ask "continue/block"
            iterate-folder folder 
        ]
    ]
]

It's that select folders folder that is messsing it up, I think.....folder is already the data structure you want.

Try this (note also the ask rather than input just to add a debugging string at that point):

iterate-folder: func [folders [block!]][
    foreach folder folders [
        either not block? folder [
            probe folder
            temp: folder
            ask "continue/not block"
    ] [
            print "folder"
            probe folder
            print "folders"
            probe folders
            probe select folders folder
            type-folder: folder
            probe type-folder
            ask "continue/block"
            iterate-folder folder 
        ]
    ]
]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文