Code to Joy by Michael Littman
Author:Michael Littman [Littman, Michael]
Language: eng
Format: epub, mobi
Tags: Computer programming; artificial intelligence; machine learning; social media; Computer literacy; Future of computing; Usability.
Publisher: MIT Press
Published: 2023-09-13T00:00:00+00:00
6
Consolidating into Loops
You Donât Have to Tell Me Twice
Whether itâs in your hairstyle, your model airplane flying, or your cereal bowl, loops make an exciting addition. Your vocabulary for conveying tasks to a computer is no different.
A loop is a set of instructions or behaviors that is repeated multiple times. The most obvious advantage of communicating tasks using loops is that you can say a lot with very few words. Imagine you are in gym class and the instructor says you need to do a pushup, a pushup, a pushup, a pushup, a pushup, rest for a moment, then do a pushup, a pushup, a pushup, a pushup, a pushup, rest for a moment, then do a pushup, a pushup, a pushup, a pushup, a pushup, and stop. Phew! The effort it took to listen to the instructions left you too tired to actually do the exercise. A more parsimonious way to express this sequence would be for the trainer to say âDo three sets of five pushups.â As the number of sets and reps (repetitions without a break) grows, the number of saved words grows exponentially.
Being able to convey a long activity in very few words is nice in and of itself, but thereâs a bunch of other advantages that come along with it. The shorter sequence is easier to remember, easier to follow, and easier to modify. It calls out the common structure in the sequence, which makes it easier to carry out the activity with less attention to the details.
Ikea, the Swedish furniture company famous for do-it-yourself assembly and meatballs, puts a lot of effort into flagging repetitions in its instructions. In the manual for its Hemnes eight-drawer dresser, it show a picture of the reverse of the piece of furniture with a whole bunch of nails standing at the ready to hold the backing board in place. But how do we secure these nails? Ikea provides a little diagram of a hammer hitting a single one of the nails into place. Should we just hammer in that one nail? No, the hammer is shown in a little speech bubble, which carries the notation â28x.â Itâs telling us that we should repeat this hammering action for all twenty-eight of the nails shown. If Ikea hadnât provided the â28x,â it might not be clear that this action should be repeated. But if it had drawn twenty-eight hammers on the diagram, it would have been cluttered and would oblige the customer to look at each of the twenty-eight pictures to see if there was some important difference. Not expressing the looping behavior explicitly makes a complicated process much, much worse.
As with the sets-reps example above, Ikea sometimes makes use of nesting, loops within loops. To walk us through attaching the drawer pulls on the Hemnes, Ikea shows a picture of a screwdriver twisting a screw into the knob to link them together. As in the nail example, the screwdriver-knob-screw group has a bubble around it with a â2xâ label, indicating we need to repeat that action for the two knobs on the drawer.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12571)
Hello! Python by Anthony Briggs(9916)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9796)
The Mikado Method by Ola Ellnestam Daniel Brolund(9779)
Dependency Injection in .NET by Mark Seemann(9340)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8300)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7084)
Microservices with Go by Alexander Shuiskov(6854)
Practical Design Patterns for Java Developers by Miroslav Wengner(6772)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6713)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6419)
Angular Projects - Third Edition by Aristeidis Bampakos(6118)
The Art of Crafting User Stories by The Art of Crafting User Stories(5648)
NetSuite for Consultants - Second Edition by Peter Ries(5580)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5385)
Kotlin in Action by Dmitry Jemerov(5066)
