Skip to content

Commit 3778517

Browse files
committed
Fix Gandalf's name
1 parent 21e59c1 commit 3778517

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lectures/lambdas.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct Person {
3535

3636
int main() {
3737
std::vector<Person> people{
38-
{"Gendalf", 55'000}, {"Frodo", 33}, {"Legolas", 2'931}, {"Gimli", 139}};
38+
{"Gandalf", 55'000}, {"Frodo", 33}, {"Legolas", 2'931}, {"Gimli", 139}};
3939
// ❌ Won't compile, cannot compare Person objects.
4040
std::sort(people.begin(), people.end());
4141
}
@@ -193,7 +193,7 @@ void Print(const std::vector<Person>& persons, const std::string& tag) {
193193

194194
int main() {
195195
std::vector<Person> people{
196-
{"Gendalf", 55'000}, {"Frodo", 33}, {"Legolas", 2'931}, {"Gimli", 139}};
196+
{"Gandalf", 55'000}, {"Frodo", 33}, {"Legolas", 2'931}, {"Gimli", 139}};
197197
Print(people, "> Before sorting:");
198198
std::sort(
199199
people.begin(), people.end(),
@@ -204,15 +204,15 @@ int main() {
204204
And now `std::sort` sorts our Tolkien characters by age in ascending order.
205205
```
206206
> Before sorting:
207-
Gendalf 55000
207+
Gandalf 55000
208208
Frodo 33
209209
Legolas 2931
210210
Gimli 139
211211
> Sorted by age ascending:
212212
Frodo 33
213213
Gimli 139
214214
Legolas 2931
215-
Gendalf 55000
215+
Gandalf 55000
216216
```
217217

218218
So let's talk about what lambdas are, how to write them in such a way that they operate safely and efficiently and, yes, how they make **this** a valid piece of C++ code :wink:
@@ -257,7 +257,7 @@ bool less(const Person& p1, const Person& p2) { return p1.age < p2.age; }
257257

258258
int main() {
259259
std::vector<Person> people{
260-
{"Gendalf", 55'000}, {"Frodo", 33}, {"Legolas", 2'931}, {"Gimli", 139}};
260+
{"Gandalf", 55'000}, {"Frodo", 33}, {"Legolas", 2'931}, {"Gimli", 139}};
261261
Print(people, "> Before sorting:");
262262
// 💡 We can also pass "less" without "&" here. Try it!
263263
std::sort(people.begin(), people.end(), &less);
@@ -322,7 +322,7 @@ class ComparisonToQueryAge {
322322

323323
int main() {
324324
std::vector<Person> people{
325-
{"Gendalf", 55'000}, {"Frodo", 33}, {"Legolas", 2'931}, {"Gimli", 139}};
325+
{"Gandalf", 55'000}, {"Frodo", 33}, {"Legolas", 2'931}, {"Gimli", 139}};
326326
Print(people, "> Before sorting:");
327327
std::sort(people.begin(), people.end(), ComparisonToQueryAge{4242});
328328
Print(people, "> Sorted by age difference to 4242, ascending:");
@@ -386,7 +386,7 @@ void MySort(Iterator begin, Iterator end, Comparator comparator) {
386386
387387
int main() {
388388
std::vector<Person> people{
389-
{"Gendalf", 55'000}, {"Frodo", 33}, {"Legolas", 2'931}, {"Gimli", 139}};
389+
{"Gandalf", 55'000}, {"Frodo", 33}, {"Legolas", 2'931}, {"Gimli", 139}};
390390
Print(people, "> Before sorting:");
391391
MySort(people.begin(), people.end(), less);
392392
Print(people, "> Sorted by age ascending:");
@@ -430,7 +430,7 @@ int main() {
430430
};
431431

432432
std::vector<Person> people{
433-
{"Gendalf", 55'000}, {"Frodo", 33}, {"Legolas", 2'931}, {"Gimli", 139}};
433+
{"Gandalf", 55'000}, {"Frodo", 33}, {"Legolas", 2'931}, {"Gimli", 139}};
434434
Print(people, "> Before sorting:");
435435

436436
std::sort(people.begin(), people.end(),

0 commit comments

Comments
 (0)