Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

那个 .. 符号,我暂且读作range吧,好像不是延迟的吧? #10

Closed
zhengxiaoyao0716 opened this issue Jan 17, 2018 · 8 comments

Comments

@zhengxiaoyao0716
Copy link

zhengxiaoyao0716 commented Jan 17, 2018

大概看了一下,貌似生成的是ArrayList?有没有类似Python3那样的优化,用延迟range替换掉直接求值的list?或者结合那个lazy语法什么的,有没有比较方便的,在延迟列表上直接遍历的实践?

@ice1000
Copy link
Collaborator

ice1000 commented Jan 17, 2018

可以将[|]lazy配合使用,我还没试过(我拿这个东西来当游戏Demo的弹幕脚本)。

成功之后写个例子进README吧。

@ice1000 ice1000 self-assigned this Jan 17, 2018
@zhengxiaoyao0716
Copy link
Author

zhengxiaoyao0716 commented Jan 17, 2018

ok、成功之后,如果有时间的话,可以再试试诸如repeat(生成无限重复一个元素或一段序列的延迟range)、example之类的(生成一段序列中一个随机元素或一段随机子序列的延迟range),当然如果只是当弹幕脚本的话没有也行。我还不熟悉你这个语言的特性,不然可以自己试着实现以下。

@ice1000
Copy link
Collaborator

ice1000 commented Jan 17, 2018

不就是惰性序列吗。我试试。

@ice1000
Copy link
Collaborator

ice1000 commented Jan 17, 2018

不过我的惰性求值只是对函数参数而言的。不知道会不会很贫瘠。

@zhengxiaoyao0716
Copy link
Author

加油!

@ice1000
Copy link
Collaborator

ice1000 commented Jan 17, 2018

我的想法是正确的,仅对于函数参数的惰性求值是不够的,还需要惰性的数据结构,which is 不支持ed by lice。

@ice1000
Copy link
Collaborator

ice1000 commented Jan 17, 2018

当然了这也超出Lice的定位了,所以我不会加了。

@zhengxiaoyao0716
Copy link
Author

抱歉现在才注意到。惰性数据结构的话,可以考虑底层用Java8的Stream啊。不过超出定位的话就没办法了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants