diff --git a/_overviews/scala3-book/scala-for-python-devs.md b/_overviews/scala3-book/scala-for-python-devs.md index 147f5977f..551bd1426 100644 --- a/_overviews/scala3-book/scala-for-python-devs.md +++ b/_overviews/scala3-book/scala-for-python-devs.md @@ -40,7 +40,7 @@ At a high level, Scala shares these *similarities* with Python: - Both have a relatively simple, concise syntax - Both support a [functional style of programming][fp-intro] - Both are object-oriented programming (OOP) languages -- Both have comprehensions: Python has list comprehensions and Scala has `for` comprehensions +- Both have comprehensions: Python has list comprehensions, dict comprehensions and generator expressions and Scala has `for` comprehensions - Both languages have support for lambdas and [higher-order functions][hofs] - Both can be used with [Apache Spark](https://spark.apache.org) for big data processing - Both have a wealth of terrific libraries @@ -693,6 +693,26 @@ Scala also has `match` expressions. +### Lazily evaluated comprehensions: + +
+ from itertools import count
+
+ |
+
+ val allSquares = for n <- LazyList.from(0) yield n * n
+
+ |
+