[Cs3] Lambda Expressions - CSIII

Mikhail Nesterenko mikhail at cs.kent.edu
Fri Sep 29 13:06:53 EDT 2017


> 
> Another question, are we allowed to use lambda expressions in order to sort
> our roster?

I would stay away from lambda expressions for this lab: you do not
need them. We are going to study lambda expressions later and have a
lab on them. 

That said, if you already coded a lambda expression, don't take it
out, you won't be penalized.

thanks,
--
Mikhail

> 
> A lambda expression is an optional 3rd parameter of the std::sort, however
> I know we have not covered them in class yet.
> 
> I just want to verify that utilizing lambda expression magic is legal.
> 
> Here is my code:
> 
> // Sort the master student registry by last name (uses a lambda expression)
>    std::sort(studentRegistry.begin(), studentRegistry.end(),
>       [](const std::list<std::string>& a, const std::list<std::string>& b) {
>          return a.front() < b.front();
>       });


More information about the cs3 mailing list