Learn Practice Daily golf Reference
Registers·Lesson 4 of 4·9 min·0/6 exercisesPro

Numbered history and the secret salsa

Every line you delete goes into jar 1 and shuffles the row along to 9: "2p puts back the delete before last, and "1p then u. walks back through them.

Scene

Monday, 9:00 a.m. You open the laptop and the editor is still open from Friday. So is the problem: at 5:50 p.m. you tidied the secret salsa with a run of dds, and one of the lines you deleted, the roasted garlic, wasn't dead. The kitchen noticed at breakfast.

It isn't in any jar you named. But every line you delete goes somewhere.

From memory

Warm-up from earlier chapters

Two from earlier chapters, from memory, before the new idea. Two wrong tries show the answer.

Copy this line to the system clipboard.
press the keys…4 keys
1 of 2
Copy this line to the system clipboard.

A row of nine jars

Next to the everyday jar stands a row of nine, labelled 1 to 9. Every time you delete whole lines, they go into jar 1, and everything already in the row shuffles one jar along: 1 to 2, 2 to 3, down to 9, and what was in 9 is gone. So the row holds your last nine line deletes, newest first.

Afterdddddd
"1 "1 clove garlic, roasted",↵
"2 "2 chiles de arbol",↵
"3 "// old: 1 cup sugar",↵
Three dd from the sugar line take sugar, then the chiles, then the garlic: the newest delete is in jar 1, the oldest in jar 3.

Pour from further along

"1p puts back the last line you deleted, "2p the one before it, "3p the one before that. If you don't know which jar it's in: "1p, and if it's the wrong line, u and .: after a numbered put, . is special and pours the next jar along. u. u. walks back through the row until the right line appears.

Before
one
two
three
end
dddddd
end
"1p
end
three
u.
end
two
Three deletes; "1p puts back three; u takes it away again and . pours jar 2: two.
Try it

Put one back

Delete the sugar line, then the garlic line, each with dd. Then put the garlic back below the chiles: it's the last delete, so "1p.

1 of 3Delete the line marked red
1export const SECRET_SALSA = [
1 "4 tomatoes, charred",
2 "// old: 1 cup sugar",
3 "2 chiles de arbol",
4 "1 clove garlic, roasted",
5 "lime juice",
6 "// old: ketchup",
7 "salt, to taste",
8];
NORMALLoading the editor…1/30.0s1:1

This exercise needs a keyboard. Read on, and play it at your computer.

Check yourself

Which jar?

1a
1b
2c
3end
NORMAL
Keys pressed: dddddd"2p

You delete a, then b, then c, each with dd, and the cursor is on end. You press "2p. What goes in below end?

Pick an answer (or press its number), then watch the engine prove it.
Check yourself

Why not just undo?

1sugar
1garlic
2ketchup
3end
NORMAL
Keys pressed: dddddduu

You deleted sugar, then garlic, then ketchup. You want the garlic back, so you press u until it appears. What does the file say then?

Pick an answer (or press its number), then watch the engine prove it.
Boss round

The secret salsa

Monday, 9:05. The editor is as Friday left it: at 5:50 you made five line deletes in a row, and somewhere in them is the roasted garlic. You don't remember which delete it was. Put the garlic back below the chiles, and leave the dead lines dead.

Stuck? Show a hint
Pro
The rest of this lesson is in Pro

The first exercise of every lesson is free. Pro unlocks the rest, every track, for good.

See Pro

This exercise needs a keyboard. Read on, and play it at your computer.

Monday, 9:20 a.m.Finish the exercise above to see it.
From memory

The whole shelf, from memory

Six situations from the shelf.

Put the last thing you yanked, even after deleting since.
scroll here, then press the keys3 keys
1 of 6
Put the last thing you yanked, even after deleting since.