Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Beginning Swift
  • Toc
  • feedback
Beginning Swift

Beginning Swift

By : Rob Kerr, Kåre Morstøl
4 (1)
close
Beginning Swift

Beginning Swift

4 (1)
By: Rob Kerr, Kåre Morstøl

Overview of this book

Take your first foray into programming for Apple devices with Swift.Swift is fundamentally different from Objective-C, as it is a protocol-oriented language. While you can still write normal object-oriented code in Swift, it requires a new way of thinking to take advantage of its powerful features and a solid understanding of the basics to become productive.
Table of Contents (10 chapters)
close

Lazy Operations


All the sequences and methods we have looked at so far this lesson have been eager, which means they perform their operations immediately, and filter, map, and flatMap return their results in arrays. But sometimes, we may want to delay operations until they are needed.

Say you have a very large array, and you want to first use map and then perform other operations. If done eagerly, map will create a new array with the same number of elements as the original one to store its results. But if we do it lazily, map will return a LazyMapSequence, which will perform each map operation directly when asked for, without using any intermediate storage.

Infinite sequences must be handled lazily, as they obviously cannot be stored.

Lazy Sequences

A lazy sequence is one that conforms to LazySequenceProtocol. The original sequence itself may or may not work lazily internally, but some further operations on the sequence...

bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete