Created
April 12, 2018 11:41
-
-
Save jimmythai/959b2e977daf32cc1ce936db79b32935 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Somthing like this: | |
| var current = 1 | |
| while current * current <= 100 { | |
| current += 1 | |
| } | |
| result = current * current | |
| // To this: | |
| let result = (1...) | |
| .lazy | |
| .map { $0 * $0 } | |
| .first(where: { $0 > 100}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment