Escaping from search

lazyList.map(fn) doesn’t run fn over lazyList elements until it’s forced. That’s the point of lazyList. Example:

LazyList(1, 2, 3).map(_ => sys.error("boom")) // doesn't throw, will throw when you run e.g. .mkString
Seq(1, 2, 3).map(_ => sys.error("boom")) // throws immediately