Scala 中的 LazyList 和 Stream 有什么区别? [英] What's the difference between LazyList and Stream in Scala?

查看:73
本文介绍了Scala 中的 LazyList 和 Stream 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到 StreamScala 2.13 中已被弃用,他们建议使用 LazyList.他们还说使用 LazyList(完全懒惰)而不是 Stream(只有懒惰的尾巴)".
它到底是什么意思?为什么他们弃用 Stream ?

I noticed that Stream is deprecated in Scala 2.13 and they suggest using LazyList. They also say "Use LazyList (which is fully lazy) instead of Stream (which has a lazy tail only)".
What does it exactly mean ? Why did they deprecate Stream ?

推荐答案

NthPortal,LazyList 的贡献者,在 更新和改进 LazyList 文档 #7842

NthPortal, a contributor to LazyList, states in Update and improve LazyList docs #7842

LazyListStream 之间的主要区别 - 及其主要功能 -是懒惰评估它是否懒惰.我不确定如何最好地传达这一点.

The key difference between LazyList and Stream - and its key feature - is that whether or not it is lazy is evaluated lazily. I'm not sure how best to convey that.

jwvh 在相关问题

Stream 元素是惰性实现的,除了第一个(头)元素.这被视为一种缺陷.

Stream elements are realized lazily except for the 1st (head) element. That was seen as a deficiency.

Scala 2.13 发行说明 state

Scala 2.13 release notes state

immutable.LazyList 替换 immutable.Stream.Stream 有不同的懒惰行为,现在已弃用.(#7558#7000)

immutable.LazyList replaces immutable.Stream. Stream had different laziness behavior and is now deprecated. (#7558, #7000)

这篇关于Scala 中的 LazyList 和 Stream 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆