Rebol select 之类的函数返回的不仅仅是下一个值?

发布于 2024-10-09 17:17:46 字数 29 浏览 0 评论 0原文

这存在吗?如果不是,创建它的最佳方法是什么?

Does this exist ? If not what's the best way to create it ?

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

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

发布评论

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

评论(2

゛时过境迁 2024-10-16 17:17:46

如果你想返回目标值之后的所有值,你可以使用下一个查找

例如:

data: copy [1 2 3 4 5 6 7 8 9]
select data 5
== 6            ;; returns the next value only.
find data 5
== [5 6 7 8 9]  ;; returns the series at that point, so ...
next find data 5
== [6 7 8 9]    ;; ... returns the series after that point.

如果你只想要接下来的N个项目,添加一个copy/部分...N

例如(接下来的三项):

copy/part next find data 5 3
== [6 7 8]

我将让您添加未找到该值时的错误代码:

next find data 0

If you want to return all the values after the target value, you can use next find

eg:

data: copy [1 2 3 4 5 6 7 8 9]
select data 5
== 6            ;; returns the next value only.
find data 5
== [5 6 7 8 9]  ;; returns the series at that point, so ...
next find data 5
== [6 7 8 9]    ;; ... returns the series after that point.

If you just want the next N items, add a copy/part...N

eg (next three items):

copy/part next find data 5 3
== [6 7 8]

I'll leave you to add the error code for when the value is not found:

next find data 0
满天都是小星星 2024-10-16 17:17:46

使用查找/尾部,

>> find/tail [a b c d e] 'c
== [d e]
>> find/tail [a b c d e] 'x
== none

Use find/tail,

>> find/tail [a b c d e] 'c
== [d e]
>> find/tail [a b c d e] 'x
== none
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文